NSTimer firedate randomly changes
NSTimer firedate randomly changes
- Subject: NSTimer firedate randomly changes
- From: Lorenzo Thurman <email@hidden>
- Date: Wed, 17 Nov 2010 14:41:57 -0600
I use two NSTimers in my app. One runs a "mini" data fetch at regular
intervals. I use another to run a "full" data fetch every 4 hours. The
problem I'm running into is that while the mini fetch runs as scheduled, the
full fetch never runs. I put some NSLog statements in the code to output the
firedate for both timers whenever the either fetch runs. What I see is that
only the mini timer fires, always on schedule, but the full fetch timer's
firedate is always offset forward by some random value in minutes so far
(+35, +42, +72, etc.) and as a consequence, it never fires. I would expect
its firedate to remain constant until it fires. I reset the mini timer after
it fires as it needs to check if the user has changed the interval, but
there is no code that resets the full fetch timer; no need, it should run
every 4 hours.
Here is the code I use to initialize the mini timer:
miniTimer = [[NSTimer scheduledTimerWithTimeInterval:[[self fetchInterval]
floatValue] * 60.0
target:self selector:@selector(myMethod) userInfo:nil repeats:NO] retain];
This code gets called after every mini fetch to ensure the timer is set
The full fetch timer is setup in init as:
fullFetchTimer = [[NSTimer scheduledTimerWithTimeInterval:14400.00
target:selfselector:
@selector(clearOldData) userInfo:nil repeats:YES] retain];
I also subscribe to the NSWorkSpaceDidWakeNotification to ensure the timers
fire if an interval was missed due to sleep, conditionally. If the full
fetch should run, then the mini fetch does not and vice-versa.
Any have any ideas whats going on?
TIA
--
"My break-dancing days are over, but there's always the funky chicken"
--The Full Monty
_______________________________________________
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