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
  • PrintPrint
Share this Page URL
Help

3. Objective-C for iOS: Email needs vari... > To keep your memory straight, you ne...

To keep your memory straight, you need to remember just two things

Memory management can get pretty hairy in larger apps, so Apple has a couple of rules established to keep track of who’s in charge of releasing and retaining when.

  1. You own objects you create with alloc, new, copy, or mutableCopy.

    If you create an object with alloc, new, copy, or mutableCopy, it will have a retain count of 1, and you’re responsible for sending a release when you’re done with the object. You can also put the object in the autorelease pool if you want the system to handle sending a release later.

    Note

    We’ll explain more about retain counts in just a bit—hang on.

  2. Assume everything else could go away at the end of the event loop unless you take ownership.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

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

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint