Ray's playground

 

Memory Management(Chapter 3 of Objective-C Phrasebook)

When you send an object an -autorelease message, it is added to the currently active NSAutoreleasePool instance. When this instance is destroyed, every object added to it is sent a -release message. The -autorelease message is a deferred -release message. You send it to an object when you no longer need a reference to it but something else might.
This is a convention that is important to observe in your own classes. If someone creates an instance of one of your classes with a named constructor, he will expect not to have to release it. A typical named constructor would look something like the one at the start of this section. 

posted on 2011-02-26 21:52  Ray Z  阅读(200)  评论(0编辑  收藏  举报

导航