Pointer Variables and Object Ownership

Pointer variables convey ownership of the objects that they point to.

  • When a method (or function) has a local variable that points to an object, that method is said to own the object being pointed to.

  • When an object has an instance variable that points to another object, the object with the pointer is said to own the object being pointed to.

Think back to your RandomPossessions application as a whole. Or, better yet, reopen RandomPossessions.xcodeproj and have another look at the code in main.m. In this application, an instance of NSMutableArray is created in the main function, and then 10 BNRItem instances are added to the array.

Figure 3.3 shows the objects in RandomPossessions and the pointers that ...

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.