In Objective-C, what is the best way to wait to execute something at a certain time (set as a timestamp that could be passed to the observer object to know what time to wait for).
For example, I would like set a time for something to ‘finish’ in the future, like building a house, and when the current time is the time that was set as a completion time by the app the app will send a notification or send a message to another object.
What is best way to do this in Objective-C?
Thank you for the help!
I assume you are talking about something that happens during the run of the program (rather than “busing a house” being a real house that gets built months from now).
The normal tool for this is
-[NSTimer initWithFireDate:interval:target:selector:userInfo:repeats:]. This will let you set a specific time to call a method. It just schedules the event on the runloop, which is very cheap.NSTimeris ideal for things that are not time-critical and have fairly long delays (more than a few seconds).