Quote:
Originally Posted by brian515
I tried what you said, and if I release the view controller right after I have pushed it, but if I try to preform the task again, the program throws an exception.
|
When you initialize your viewcontroller, set it to autorelease before you push the viewcontroller.
That way, when you push the viewcontroller, it will be added to the viewcontroller stack and autorelease will decrement its retain count.
When you pop the viewcontroller later, its retain count will be decremented to 0, and dealloc will be called, freeing the memory previously allocated to the viewcontroller.
Dollop's method works too, but you need to somehow keep track of the viewcontroller between the push and the pop. Using autorelease is easier.