Re: Best pattern to follow for scheduling an event
Re: Best pattern to follow for scheduling an event
- Subject: Re: Best pattern to follow for scheduling an event
- From: glenn andreas <email@hidden>
- Date: Thu, 8 Nov 2007 12:37:17 -0600
On Nov 8, 2007, at 12:27 PM, John Stiles wrote:
Would this work more than once?
The current code works if you call it multiple times in a row.
With a non-repeating timer, the docs say it will invalidate itself
as soon as it has fired.
So, assuming I'm following this correctly, the cleanup happens only
once, at the next run of the event loop, even though it may be
requested multiple times (both between the first call and the time it
actually runs, as well as after it has already run once). Then the
init part would be:
m_deferredFixupTimer = [[NSTimer alloc] initWithFireDate: [NSDate
distantFuture] interval: 0 target: myObject selector:
@selector(doFixUp:) userInfo: NULL repeats: NO];
[[NSRunLoop currentRunLoop] addTimer: m_deferredFixupTimer forMode:
NSDefaultRunLoopMode];
and then "trigger" part would be:
[m_deferredFixupTimer setFireDate: [NSDate date]];
[m_deferredFixupTimer release];
m_deferedFixupTimer = nil;
After the first time it is triggered, the thing will be nil, so no
problem...
Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium | flame : flame fractals & strange attractors : build,
mutate, evolve, animate
_______________________________________________
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