WWDC24 SALE: Save 50% on all my Swift books and bundles! >>

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!

   

Save 50% in my WWDC sale.

SAVE 50% To celebrate WWDC24, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

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.