|
My data model is shown below. Not sure why the Order class will not comply with Codable when it only contains a Codable var orderDetail?
|
|
|
|
I was assuming I would need to save the JSON from the class, but now you mention it I guess I can just save and load the OrderDetail var? |
|
But... What to do with the required init that does nor seem to work for a struct? |
|
Gerry gets a coded message from the compiler! I simplified your
The error messages states the compiler:
If you remove the property wrapper, this compiles just fine. Xcode is able to synthesize the So the |
|
OK. The original version (before challenge 3) addressed the published/Codable issue by adding encode/decode steps for the class. This challenge was to wrap a struct in a class which I thought was intended to simplify the codable problem. So, I am looking for a way to encode the class which does not have the vars used in the CodingKey or in the required init. Not sure how this is going to be simpler right now?! Here is where I am with an error on the required init for the struct, and no simplification...
|
SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.
Sponsor Hacking with Swift and reach the world's largest Swift community!
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.