• 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: Unwanted retain
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unwanted retain


  • Subject: Re: Unwanted retain
  • From: Ryan Bates <email@hidden>
  • Date: Thu, 5 Feb 2004 17:05:50 -0800

On 5 Feb, 2004, at 9:27 AM, b.bum wrote:
While Clark might be correct, it is completely and totally irrelevant to consider what the run loop might or might not be doing to the retain count of the timer. Reading the documentation for NSTimer and NSRunLoop, neither mention anything about retaining the timer. While the Run Loop might retain the timer for its own purposes, that is none of your business as a Cocoa developer! :-)

While I agree it is irrelevant, the Apple docs do say the run loop retains the timer:

"Note that run loops retain their timers, so you can release the timer after you have added it to a run loop."
<http://developer.apple.com/documentation/Cocoa/Conceptual/Timers/ Tasks/createtimer.html>

Here are a couple of rules that might help everyone with NSTimers (and hopefully won't cause extra confusion):
- A timer retains the target and userInfo objects.
- A timer is automatically retained by the run loop when scheduling it.
- If a timer is not set to repeat, it will automatically invalidate itself upon firing.
- A timer is released from the run loop when calling invalidate.
- A timer releases the target and userInfo objects when calling invalidate.

Ryan Bates
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Unwanted retain
      • From: "b.bum" <email@hidden>
    • Re: Unwanted retain
      • From: "b.bum" <email@hidden>
References: 
 >Re: Unwanted retain (From: Lorenzo <email@hidden>)
 >Re: Unwanted retain (From: Dustin Voss <email@hidden>)
 >Re: Unwanted retain (From: "b.bum" <email@hidden>)
 >Re: Unwanted retain (From: Clark Cox <email@hidden>)
 >Re: Unwanted retain (From: "b.bum" <email@hidden>)
 >Re: Unwanted retain (From: Dustin Voss <email@hidden>)

  • Prev by Date: Re: Are we still supposed to register Creator code (bundle signature) for OS X app?
  • Next by Date: Re: base64
  • Previous by thread: Re: Unwanted retain
  • Next by thread: Re: Unwanted retain
  • Index(es):
    • Date
    • Thread