Class Initialization
The general syntax for initialization in classes looks very similar to initialization in value types. Nonetheless, there are some different rules for classes that must be observed. These additional rules are mainly due to the fact that classes can inherit from other classes, which necessarily adds some complexity to initialization.
In particular, classes add the concepts of designated and convenience initializers. An initializer on a class is either one or the other. Designated initializers are responsible for making sure that an instance’s properties all have values before initialization completes, thus making the instance ready to use. Convenience initializers supplement designated initializers by calling ...
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