|
Hi all, Based on the expense project, i tried to apply the what i learned on an app. However i am facing an issue that i am not able to find a solution. I have two sections: the first one contains ingredients and the second section which is empty should have all ingredients choosed from the first section. I have created a class, which i add items that needs to added to the second section. I am able to add items, however when i check the Thanks
|
|
The above initialises a new instance every time, thus if you don't have anything predefined it will be empty. You should pass around the @ObservedObject like this:
|
|
@Bern, Thanks for your response. I have tried it but no result. I still see 0 elements in
Quick question, the fact that uei this code below, shouldn't it work. My understanding is that class are reference type, so it should point to the same object unless i overrride it. Am i missing something ?
|
|
Here you have defined the
See if this helps
Be careful that your
Also, as Bnerd has already stated, the ObservedObject should declared as
See here for an explanation. |
SPONSORED Play is the first native iOS design tool created for designers and engineers. You can install Play for iOS and iPad today and sign up to check out the Beta of our macOS app with SwiftUI code export. We're also hiring engineers!
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.