Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 3. Memory Management > Using Autoreleased Constructors

Using Autoreleased Constructors

From: namedConstructor.m

4 + (id)object
5 {
6   return [[[self alloc] init] autorelease];
7 }

I said in the last section that objects created with +alloc have a retain count of one. In fact, all objects are created with a retain count of one, but objects created with a named constructor, such as +stringWithFormat: or +array, are also autoreleased.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial