Initializers
Instance methods that initialize a newly allocated instance are called initializers and, by convention, begin with the word init. The Objective-C compiler does not ensure correct initialization of object instances, therefore initialization must be handled by convention. The initialization convention is not optional for existing Cocoa classes or for most subclasses of Cocoa classes. By convention, object instances are created in two steps. First, memory for the new instance is reserved by calling the +alloc or +allocFromZone: class methods provided by the NSObject class. Almost all classes in the Cocoa frameworks inherit directly or indirectly from NSObject. After memory is reserved, the memory is initialized by calling an initializer. ...
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