December 2015
Intermediate to advanced
400 pages
13h 3m
English
Structures can have both default and custom initializers. When working with structs, you will typically want to take advantage of the default initializer provided, but there are some circumstances in which you will want to customize the initialization process.
Remember how you have been getting instances of your Town type?
You gave the type’s stored properties default values.
What you did not know is that you were taking advantage of an empty initializer (an initializer without parameters) provided to you by the Swift compiler automatically.
When you entered code like var myTown = Town(), that syntax called the empty initializer and set the new instance’s properties to ...
Read now
Unlock full access