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

Day 85 - Hot Prospects - Challenge #2

Forums > 100 Days of SwiftUI

Hi, Can someone point me in the right direction how to approach challenge #2: Add an editing screen, so users can adjust the name and email address of someone they scanned previously. (Tip: Use the simple form of NavigationLink rather than navigationDestination(), to avoid your list selection code confusing the navigation link.)? I'm struggling with how to pass original prospect to edit view through navigationLink.

   

Tip:

Paul uses SwiftData in this project. The Prospect class uses the @Model macro which as we have learnt, already uses @Observable under the hood. What does this tell us? We can use @Bindable to share observable state between views.

Breaking it down, this means you could possibly:

1) Create an edit view 2) Pass in a @Bindable prospect into that view 3) Bind the properties of the prospect to the text views such as the name/ email address and that's really it!

The beauty of this is that the object is already updated and saved in SwiftData.

1      

Thank you for the tip!

   

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

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

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.