|
Hi, I've tried to solve Project 10 Challenge 3 and I saw a couple of posts here, but none of them seemed to work. Questions:
Here is my code: Order
CheckOut View
AddressView:
ContentView:
|
|
HINT: In your All the other errors you list are probably side effects of one error. Once you solve the big problem, the others may very well disappear. |
|
@Obelix: Thank you for the hint. I declared order in Checkout View as @State var order : Order since it is impossible to make order Struct conform to the ObservableObject protocol. A similar change was also made in AddressView. I do observe that in Challenge 3, with a Struct approach instead of a Class, when I enter the address details and then lick "back", and then go to the address page again, all information is lost, which I believe speaks to the "value type vs. reference type" thing ? |
|
Right on! I love it when the lightbulbs come on. Nice. I may have ranted a few times about naming objects. If my coding team were to peer-review your code, this would certainly be one of the team's comments. I think you tripped yourself up by taking shortcuts with your struct and class names. While you're learning, feel free to be overly verbose when naming your structs and classes. For one, it helps you solidify the concepts in your head. Verbose names also help you with your logic. Compare:
Another good reason may have helped in your situation. You have this:
You used Order to describe a struct, then reused this word as the name of a variable. Yikes! Which are you using? The struct, the class, or the variable. Confusing. Maybe a better name could be:
|
|
SAVE 50% All our books and bundles are half price for Black Friday, 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.
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.