• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Autorelease question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Autorelease question


  • Subject: Re: Autorelease question
  • From: Jens Alfke <email@hidden>
  • Date: Fri, 4 Apr 2008 09:31:33 -0700


On 3 Apr '08, at 5:50 PM, Adam Leonard wrote:

If you are writing a tool that links with Foundation and not AppKit, an autorelease pool is NOT created for you. As you saw in your first example, you need to explicitly create and destroy one whenever you are dealing with Foundation objects in a method.

It depends. At the outermost scope, like the main() method and things called directly by it, you have to create your own pools. But if your process uses NSRunLoop, that class ensures that everything it calls is in the context of an autorelease pool. So you don't have to worry about this when writing delegate/target methods for NSTimers, NSURLConnections, etc.


Of course, it doesn't hurt to add your own anyway, if you want; it's just a very small performance overhead.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Autorelease question (From: Dmitry Markman <email@hidden>)
 >Re: Autorelease question (From: Adam Leonard <email@hidden>)

  • Prev by Date: Re: How to create process independent of current process AND that takes command line arguments?
  • Next by Date: Re: How to create process independent of current process AND that takes command line arguments?
  • Previous by thread: Re: Autorelease question
  • Next by thread: Re: Modify Input in NSTableView
  • Index(es):
    • Date
    • Thread