[ACCEPTED]-Objective-C autorelease memory management-cocoa-touch
An autoreleased object is added to an autorelease 12 pool.
Objects in the autorelease pool are 11 released at the end of an iteration of the 10 main runloop (or sooner if you are managing 9 your own autorelease pool and/or if you 8 call drain).
When you call a method that 7 returns an autoreleased object, it is pretty 6 much guaranteed to stay valid until at least 5 the end of the scope that it was called 4 in.
If you want to ensure that it stays alive 3 longer then you should retain it, remembering 2 to release it again when you're finished 1 with it.
How can i safely use the returned autoreleased 7 object inside my runIt method if i dont 6 know when the autorelease trigger?
Autorelease 5 will trigger after the current run loop 4 ends.
Should i retain the object returned 3 by the createNewTest ? or can i safely use 2 it within the runIt scope?
You can safely 1 use it inside the runIt scope.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.