O'Reilly logo

Swift Programming: The Big Nerd Ranch Guide by John Gallagher, Matthew Mathias

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required