Initialization

Initialization is the process of getting the instance of a class or structure ready for use. In initialization, you take all things that do not have values and give them values. You can also do things like call methods, and do other initializations. The big difference between Objective-C initializers and Swift initializers is that Swift initializers do not have to return self. The goal of Swift initializers is to give a value to everything that does not have a value. Structs can define initializers even though they have their own memberwise initializers. You can also define multiple initializers for a class or struct. The simplest type of initializer is one without any parameters. They are used to create a new instance of its type. ...

Get Learning Swift™ Programming 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.