Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

iamakimmer

macrumors newbie
Original poster
Apr 21, 2009
3
0
Hi,

Can someone point me in the right direction? I want to trigger an method when it hits a certain dynamic time that I set. For example at 9:00 PM today I want to call a method. The app will be running continuously. Would NSTimer be the best option for this? The only question I have with NSTimer would be what would my interval be, as the examples I've seen on NSTimer are intervals such as seconds or minutes. Is there a way to send NSTimer a future date?

Thanks for your help!!
 
Just set the interval on the timer to be the future date minus the current date (both in seconds). This is easy to do with -[NSDate timeIntervalSinceDate:]
 
or just use
Code:
- (id)initWithFireDate:(NSDate *)date interval:(NSTimeInterval)seconds target:(id)target selector:(SEL)aSelector userInfo:(id)userInfo repeats:(BOOL)repeats

of NSTimer

but in any case, I would be interested in what you are trying to do, since I can't imagine an app so great the user would keep it running all the time :D
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.