|
Hi! What is wrong with this code and why does this work for a Picker but not a List?
|
|
Your syntax for List is incorrect. Try this:
or this is how I would write it:
|
|
|
|
Sorry, I must have misunderstood. What are you trying to do with the list? You can't select an item in a List. You could add a button in each cell in the list...
|
|
I did go with the Buttons solution but wasn't sure if that was the proper solution. Thanks! |
|
I posted the same question a couple days ago. If you can not select a row in a list, then why have the "selection" available in the syntax? Is it for setting the item and not for determining the selection? If so, then how would I impliment the ability to select a row and add a child to it? Adding a button to every item in a list seems kind of clunky. TIA |
|
I have similar code in a mac app which allows list item to be selected. Mine uses a ForEach though :
|
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.