Saving Data in iOS · Codable Types | Ray Wenderlich

This is a companion discussion topic for the original entry at

Hi @jessycatterwaul, thanks for the great course. I have a question. Why didn’t the member-wise initialiser work for the Sticker struct? I tried initializing the member variables with var and it didn’t work as well.

At 5:08, I go over how it’s due to Swift not synthesizing a memberwise initializer for public access.

As for the var situation, I’m not sure what you’re asking. Please share a code snippet if you’re still working on this!

Hi, sorry for the confusion. I meant I tried changing the public let keyword to var to see if the member-wise initializer could work (which wouldn’t change anything :sweat_smile:). I get what you mean now. It is not publicly available. I was confused because I used to work on a project which I had a struct on one folder (group) and I could initialize it on a viewcontroller in another folder without having to write a boilerplate initializer. I’m still not sure why that one worked but I guess I might have missed something there. Thanks a lot anyway!

If you have files in separate folders in an Xcode project, the default option is for them to still be included in the same module, resulting in all the code in those files being able to communicate if you don’t modify the default access for that code, which is internal. There’s no way to elevate a memberwise initializer from internal to public, unfortunately, so you have to write it yourself if you want other modules to be able to use it. A playground page and its Sources folder are two different modules, for example. I’m not convinced that was a good design, but hopefully this clears things up a little bit.

He Jessy, this is sooo clear. Thanks a lot for taking time to answer me. I really appreciate it :vulcan_salute::grinning:

1 Like

Am I supposed to know everything in it by heart?? or Just understanding is good enough to move on??

Knowing any material by heart is going to make it faster to get things accomplished. But fortunately, software development is a lot more like composing a musical score rather than performing it. You can take all the time you need, and you’ll just decrease your development time as you gain experience.

Knowing that you can understand what you’re learning is important, but it’s also important to be able to find the information that you’ve learned, later, so you can study it again as you need to. Fortunately, search engines have made it so that we don’t need to take as copious of notes as we used to, in order to retrieve information in the world, but there’s still going to be a balance of mental cues, and a bookmarking system of some kind, that will be optimal for each individual. The trouble with telling you exactly how to do that is that it will be a unique mix.

In terms of the content on our site, feel free to explore in any order you like. We try to structure things so that they build on each other, but if you’re new to what we teach, you should expect that if you were to get through a lot of episodes, and then watch them again in order, that you’d understand all of the earlier ones better on later viewings. You’ll learn a lot just by being immersed, seeing concepts used in many contexts, even if you don’t understand them as well as you want to. You can think of it like living in a foreign country without being a native speaker of the local language.

Good luck and have fun!

This is just all I would love to hear. I totally get that you mean. Thank you for your time.

1 Like

Hi Ray Wenderlich team. I’m really loving the iOS and Swift for Beginners path, I’m very grateful for all of the well organized content.

One piece of feedback, I’ve noticed that it takes me a couple watch throughs of some videos before I really understand what it is that I’m doing and why I’m doing it. This video especially, it would be very beneficial to me if the video began with an overview of what we will be doing and why. To me, it’s initially clear that this lesson is about learning about the Codable protocol and how to encode JSON data, but then from there it feels like I’m just typing/executing code. Taking some time to layout a high level bullet point list of the main things we will be doing before diving into the bullet points themselves would add modular context that I could refer back to.

Currently, it feels like one long coding marathon that I get lost in. Throughout the video, you do pause to explain what it is that we just did every few minutes, but I’m still initially having trouble seeing how any one chunk fits into the bigger picture of what the lesson is actually about.

1 Like

@bachir0321 Thank you for your feedback - much appreciated! We will take it into account when we update the course.

Sorry my last post was a typo, but actually I cant compare the json due to:

**error: binary operator '==' cannot be applied to two 'Sticker' operands**

**jsonSticker == sticker**

could you share an update ?

Without seeing your code, the only reason I can think of is that you missed adopting Equatable (at the 1:35 mark in the video). If that’s not the case, upload your version of the project and I’ll have a look!

Thank you, it Works like a Charm. I missed the Equatable

1 Like