Chapter 12
Initializing and Deinitializing Data
In This Chapter
Understanding the reasons for initialization
Initializing properties and variables
Creating initializers and adding parameters
Observing changes to properties
Deinitializing properties and variables
In Swift, every instance of a class, structure, or enumeration must be initialized before being used. Accordingly, Swift gives you several ways to create various types of initializers to handle the process. You can also perform the initialization yourself by setting an initial or default value, which initializes the instance. In addition, many parts of the Cocoa and Cocoa Touch frameworks handle initialization for you.
For example, if you use Interface Builder to design your interface in Xcode, you can draw views and other interface elements on the Xcode canvas. At runtime, the framework instantiates the views and other interface elements that you have drawn, and in the process, it initializes them.
As another example, consider ...
Get Swift For Dummies now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.