O'Reilly logo

Learn Objective-C on the Mac: For OS X and iOS, Second Edition by Scott Knaster, Waqar Malik, Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 10

Object Initialization

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required