In iPhone SDK 3.0, I would like to register for a notification, which would alert my application when a certain time is reached. Is it possible? Thanks
Assuming you have a NSDate
in the variable date
, and want to fire the method dateIsHere:
at that date, do this:
NSTimer* timer = [[NSTimer alloc] initWithFireDate:date
interval:0.0f
target:self
selector:@selector(dateIsHere:)
userInfo:nil
repeats:NO];
[[NSRunLoop mainRunLoop] addTimer:timer
forMode:NSDefaultRunLoopMode];
[timer release];