Re: NSTimer not firing if date changed in Sys Prefs
Re: NSTimer not firing if date changed in Sys Prefs
- Subject: Re: NSTimer not firing if date changed in Sys Prefs
- From: Ricky Sharp <email@hidden>
- Date: Thu, 31 Mar 2005 06:30:14 -0600
On Wednesday, March 30, 2005, at 10:32PM, Sean McBride <email@hidden> wrote:
>If I create an NSTimer scheduled to fire at a particular NSDate, add it
>to the runloop, then change the date in System Preferences, the timer
>does not fire at the right time. Has anyone else seen this? I create my
>timer like so:
>
>NSCalendarDate* now = [NSCalendarDate calendarDate];
>NSCalendarDate* almostMidnight =
> [NSCalendarDate dateWithYear:
> [now yearOfCommonEra]
> month:[now monthOfYear]
> day:[now dayOfMonth]
> hour:23
> minute:59
> second:59
> timeZone:[now timeZone]];
>
>NSTimer* timer = [[NSTimer alloc]
> initWithFireDate:almostMidnight
> interval:0.0f
> target:self
> selector:@selector(handleDayChange:)
> userInfo:nil
> repeats:NO];
>
>[[NSRunLoop currentRunLoop] addTimer:timer
> forMode:NSDefaultRunLoopMode];
>
>So say I run the above code at 22:00, then change the clock to 23:59, my
>timer does not fire a minute later.
>
>Am I expecting too much? :)
I wouldn't say so. While it may be a very rare case that the user changes their time, it may happen twice a year automatically depending on if the time will auto-adjust for daylight savings.
--
Rick Sharp
Instant Interactive(tm)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden