Using Instances

To use an instance of a class, you must have a variable that points to that object. A pointer variable stores the location of an object in memory, not the object itself. (It points to the object.) A variable that points to a Party object is declared like this:

P​a​r​t​y​ ​*​p​a​r​t​y​I​n​s​t​a​n​c​e​;​

Creating this pointer does not create a Party object – only a variable that can point to a Party object.

This variable is named partyInstance. Notice that this variable’s name does not start with an underscore; it is not an instance variable. It is meant to be a pointer to an instance of Party.

Creating objects

An object has a life span: it is created, sent messages, and then destroyed when it is no longer ...

Get iOS Programming: The Big Nerd Ranch Guide 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.