How to properly create and destroy NSTimers?
How to properly create and destroy NSTimers?
- Subject: How to properly create and destroy NSTimers?
- From: Pierre-Olivier Latour <email@hidden>
- Date: Mon, 01 Jul 2002 11:47:18 +0200
Hi,
I'm playing with the NSTimer class and I find the documentation rather
obscure, so I have a few questions:
1) according the Cocoa standard, when creating a NSTimer with a method like
"scheduledTimerWithTimeInterval", it should return an autoreleased object,
which would be released at the end of the current event processing. But the
timer is going to fire later than this moment. So is the timer an
autorelease object or not? If repeat is OFF, is it going to autorelease
automatically when it has fired?
2) The doc says:
"There is no method that removes the association of a timer from an
NSRunLoopsend the timer the invalidate message instead. invalidate disables
the timer, so it no longer affects the NSRunLoop."
This is not really clear: when I call "invalidate", does it disable the
timer and I can reschedule it later (how?) or does it destroy the timer?
When the "invalidate" message is sent, is the timer object released or to I
have to send a "release" message next?
3) Is it safe to invalidate a timer before it has even fired once?
Thanks!
_____________________________________________________________
Pierre-Olivier Latour email@hidden
Manager and Lead Programmer
French Touch software
http://www.french-touch.net
Cool source code:
http://www.french-touch.net/CodeWareHouse
_______________________________________________
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.