Say I have an object initialized right before a method’s return statement…
MyObj* myObj = [[MyObj alloc] initWithOpt1:opt1 withOpt2:opt2];
return myObj;
Is it possible to release it after the return statement? Doing so before defeats the purpose of init’ing it to begin with, right? Otherwise, what’s the best way to handle this?
Autorelease was created precisely to solve this problem.
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmAutoreleasePools.html