|
I have written code to select from two lists of strings, with two "boxes" on screen. It works, no problems.
It would be a nightmare to add more selections.
How would you write this using the swiftui coding phylosophy? Hard coding like this just does not work so well
Just looking for ideas on how to handle these types of things
|
|
The best way to reduce complexity in SwiftUI is to refactor your It also helps to take advantage of Swift's powerful type system, especially Anyway, here's one way it could be done:
I hope I've added enough commennts to explain what's going on. If you need more help understanding, don't hesitate to ask. |
|
slight typo in the foreach, s/b GolfSequenceItem, but other than that, works fine. Just what I was looking for. Old School was create a dimension in the array. Swift Scool, create a view of the dimension. Lovely... I've used enums for ages, but I'm still struggling with the power of them in the Swift environment. Thanks for the lesson |
|
Ack, sorry about that. I was making tweaks and updating my post as I did so and must have gotten a little out of sync between Xcode and the post. It should be:
Though just for giggles, here's what I tweaked it to that caused my mistake:
And then in
Either way works fine, but go with whatever works best for you. (I also looked at |
SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.
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.