WWDC24 SALE: Save 50% on all my Swift books and bundles! >>

Day 17 - Creating pickers in a form - Error

Forums > 100 Days of SwiftUI

I get this error when I add a modifier (.navigationLink) to a Picker

Trailing closure passed to parameter of type 'FormStyleConfiguration' that does not accept a closure

var body: some View {
        NavigationStack {
            Form {
                Section {
                    TextField("Amount", value: $checkAmount, format: .currency(code: Locale.current.currency?.identifier ?? "USD"))
                        .keyboardType(.decimalPad)

                    Picker("Number of people", selection: $numberOfPeople) {
                        ForEach(2..<100) {
                            Text("\($0) people")
                        }
                    }
                    .pickerStyle(.navigationLink)
                }

                Section {
                    Text(checkAmount, format: .currency(code: Locale.current.currency?.identifier ?? "USD"))
                }
            }
        } 
    }

XCode Version 14.0.1 (14A400)

   

Using Xcode Version 15.3 (15E204a) and everything works fine. Think that you are using an old version of Xcode. Make sure that Minimum Deployment is iOS16 or higher

1      

I wish I could help you but I have just hit the same problem.

I added the pickerStyle to my code and got the following two errors.

On the Section { line there is the message - Struct 'ViewBuilder' requires that 'EmptyTableRowContent<V> conform to 'TableRowContent'

On the .keyboardType(.decimalPad) - Static method "buildExpression' requires that 'some View'. conforms to 'TableRowContent'

Maybe some one wll be able to help us both.

   

I am using the same version of Xcode and on the latest version of IOS

   

Save 50% in my WWDC sale.

SAVE 50% To celebrate WWDC24, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.