Chapter 10
ObjectInitialization
so far, we've created new objects in two different ways. The first way is [SomeClass new]
, and the second is [[SomeClass alloc] init]
. These two techniques are equivalent, but the common Cocoa convention is to use alloc
and init
rather than new
. Typically, Cocoa programmers use new
as training wheels until they have enough background to be comfortable with alloc
and init
. It's time for your training wheels to come off.
Allocating Objects
Allocation is the process by which a new object is born. It's the happy time when a chunk of memory is obtained from the operating system and designated as the location that will hold the object's instance variables. Sending the alloc
message to a class causes that class to allocate ...
Get Learn Objective-C on the Mac 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.