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
scott_r...@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to