Using Instances
An instance of a class (an object) has a life span: it is created, sent messages, and then destroyed when it is no longer needed.
Creating objects
To create an object, you send an alloc message to a class. In response, that class creates an object in memory and gives you a pointer to it. Creating an object looks like this:
NSMutableArray *arrayInstance = [NSMutableArray alloc];
Here an instance of type NSMutableArray is created, and you are returned a pointer to it in the variable arrayInstance. When you have a pointer to an instance, you can send messages to it. The first message you always send to a newly allocated instance is an initialization message. Although sending ...
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