No, alloc and release do not always occur in the same function. For example, one object creates another object (and stores a pointer to it) at init time...then at dealloc time, releases it. Very common.
No, alloc and release do not always occur in the same function. For example, one object creates another object (and stores a pointer to it) at init time...then at dealloc time, releases it. Very common.
To elaborate on this, imagine that you have an object of class Car that needs to access another object of class Wheel for Car's entire life span. You would want to create the Wheel when you create the Car, retain it. And then you release the Wheel when dealloc is called on the Car. Here would be init and dealloc for Class Car.