• 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: NSTimer memory management
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTimer memory management


  • Subject: Re: NSTimer memory management
  • From: Scott Ribe <email@hidden>
  • Date: Wed, 22 Sep 2010 21:34:48 -0600

On Sep 22, 2010, at 7:50 PM, Jeff Johnson wrote:

> The NSTimer API is somewhat unfortunate. It would probably be better to have a delegate API where the delegate is not retained. However, that ship has sailed. What you need to do is avoid the retain cycle. What I sometimes do is to create a private timer target that posts an NSNotification when the timer fires, and then your owning object with theTimer ivar is added as an observer of the notification. Your object is the owner of both the timer and the timer target, but there is no retain cycle.

How about: just don't retain the timer? It is not the ordinary Cocoa memory management pattern, but it works perfectly well.

--
Scott Ribe
email@hidden
http://www.elevated-dev.com/
(303) 722-0567 voice




_______________________________________________

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: 
 >NSTimer memory management (From: "email@hidden" <email@hidden>)
 >Re: NSTimer memory management (From: Jeff Johnson <email@hidden>)

  • Prev by Date: [ANN] Release: NanoStore 1.0 for Mac and iOS
  • Next by Date: Re: [ANN] Release: NanoStore 1.0 for Mac and iOS
  • Previous by thread: Re: NSTimer memory management
  • Next by thread: Re: NSTimer memory management
  • Index(es):
    • Date
    • Thread