Jens Alfke wrote:

On 1 May '08, at 4:49 PM, Western Botanicals wrote:

[NSTimer scheduledTimerWithTimeInterval: defaultSleepTime target:
self selector: @selector(run:) userInfo: nil repeats: YES];

That timer is autoreleased, so you have to retain it or it'll go away
after your init method returns.

Not unless the docs are lying (and based on heavy timer usage in some of my apps, I'm going to claim they're not). From the NSTimer overview:

"Note in particular that run loops retain their timers, so you can release a timer after you have added it to a run loop."

That said, proper conformance to the memory contract would be that you *do* retain it if you do this...

Typically you'd then assign it to an ivar; then when you need to stop the
timer, you call -invalidate and -release on it.

But as long as the OP has no intention of manually invalidating the timer, what's already there is sufficient.
_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to