UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

'TextField<Text>' has no member 'keyboardType'

Forums > SwiftUI

I just start to learn <100 days of swiftui>, and doing Day 17. I coded following:

var body: some View {
        Form {
            Section {
                TextField("Amount", text: $checkAmount)
                        .keyboardType(.decimalPad)
            }
        }
    }

IDE prompts "Value of type 'TextField<Text>' has no member 'keyboardType'" Can anyone help me fix it? I checked Google, have no result.

3      

What is the property type of your $checkAmount value? Is it a String?

3      

It seem to be a bug within swift because the .decimalPad and .numberPad give this warning I assume because it a textfield that you are entering it to and swift know these are numbers. It works fine just ignore it or use .numbersAndPunctuation as this does not give warning.

3      

Yes It is string. Probably it is swift bug, because I found my code is same to others.

3      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.