Initialization Going Forward
“How am I going to remember all this?” We hear you. Initialization in Swift is a very defined process with a lot of rules. Thankfully, the compiler will remind you of what you need to do to comply and write a valid initializer. Rather than memorizing all of the rules to initialization, it is useful to think of Swift initialization in terms of value types and classes.
For value types, such as structs, initialization is principally responsible for ensuring that all of the instance’s stored properties have been initialized and given appropriate values. This statement is true for classes as well, but initialization is a bit more complicated in this case.
Initialization for classes can be thought of as unfolding ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access