All Objective-C objects are stored in a part of memory called the heap. When we send an alloc message to a class, a chunk of memory is allocated from the heap.
This chunk includes space for the object’s instance variables.
Pointer variables convery ownership of the objects that they point to.
1. 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.
2. 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.
The idea of object ownership helps us determine whether an object should be destroyed.
1. An object with no owners should be destroyed. An ownerless object cannot be sent messages and is isolated and useless to the application. Keeping it around
wastes precious memory. This is called a memory leak.
2. An object with at least one owner must not be destroyed. If an object is destroyed but another object or method still has a pointer to it (or, more accurately, a
pointer to where it used to live), then you have a very dangerous situation: sending a message to an object that no longer exists will crash your application.
This is called premature deallocation.