Im new to obj-c and have trouble understanding the function autorelease. could someone explain to me when i should use it? and how is it different than release. also do I need to reset the autorelease pool? how? and when?
Im new to obj-c and have trouble understanding the function autorelease. could someone explain
Share
Calling
autoreleaseschedules areleasemessage to be sent to an object sometime in the near future by adding the object to the topmostNSAutoreleasePool. When a pool receives thedrainmessage, it sendsreleaseto all the objects that have been added to it.autoreleaseis used in situations where a method or function needs to relinquish its ownership of an object, but needs to keep it from beingdeallocated temporarily so that its caller can do something with it. It’s also useful in creating “convenience” methods that wrapalloc,initWith...andautoreleaseto make code that allocates objects simpler.