Re: NSTimer memory management
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