|
Failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project import SwiftUI struct ContentView: View { @State private var checkAmount = 0.0 @State private var numberOfPeople = 2 @State private var tipPercentage = 20 @FocusState private var amountIsFocused: Bool
} struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } |
|
Two problems:
but this makes
which would be of type (If you truly want to allow the user to select any tip percentage from 0 to 100, you can do this:
But given that this is a segmented |
|
When posting code to these forums, place three backticks This makes it far easier to read and also makes it easier for other posters to copy/paste the code in order to test solutions and such. Doing this will ensure that you end up with something like this:
instead of this: func printSomething(_ thing: String?) { if let thing = thing { print(thing) } else { print("nothing there") } } |
|
May I add? This is not a very useful title: I have a problem. Help me please. Please help us to help you. Provide a useful title. Think of others who read the forum looking for solutions. Your title won't help anyone understand your issue. Instead, they will have to open your post to read the content and wasting their time if their problem isn't related to yours. When you provide a descriptive title, others can scan posts to quickly weed out questions or problems not related to their search. |
SPONSORED Alex is the iOS & Mac developer’s ultimate AI assistant. It integrates with Xcode, offering a best-in-class Swift coding agent. Generate modern SwiftUI from images. Fast-apply suggestions from Claude 3.5 Sonnet, o3-mini, and DeepSeek R1. Autofix Swift 6 errors and warnings. And so much more. Start your 7-day free trial today!
Sponsor Hacking with Swift and reach the world's largest Swift community!
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.
Link copied to your pasteboard.