⌘-R in Chief
And it's still autoreleased properly because the autorelease pool has a reference to it. When the autorelease method is called (whether by your or any other method), it finds the pool on the top of the stack, and that pool keeps a reference to the object. When the pool is deallocated, it sends a release message to every object it has a reference to.
Gillissie Wrote:Thanks for the additional info.The real answer for this depends on what your definition of "create" is. If you "create" autoreleased objects, then your variable can be assigned and reassigned to your heart's content without causing a leak. If, however, you "create" retained objects, you must make sure to release the existing object in your variable before reassigning to a new object or you'll have leaks.
So what happens if you create a NSString object, then create another object using the same variable in the same scope? Does the first one still get autoreleased, or is it a memory leak? I would like to create several audio objects, and I would like to re-use the soundFilePath variable.
Possibly Related Threads...
|Is implementing autorelease code in constructor a good idea ?||Bracer||4||3,174||
Oct 13, 2009 12:41 PM
Last Post: SethWillits
|Track down an autorelease bug||kendric||2||3,574||
Jun 28, 2009 05:09 AM
Last Post: kendric