TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

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!

   

Hacking with Swift is sponsored by Superwall.

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn 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.