Hi guys,
How would I be able to use timers? For example I want to show a certain text for 10 seconds and then I want to show a different text for the rest of the duration.
Thanks,
Kevin
Hi guys,
How would I be able to use timers? For example I want to show a certain text for 10 seconds and then I want to show a different text for the rest of the duration.
Thanks,
Kevin
The easiest way to defer an action is to use NSObject's performSelector:withObject:afterDelay:
- (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay
Set your text the first time (or at init time) and then do something like:
[self performSelector:@selector(changeText) withObject:nil afterDelay:10.0];
You can cancel the request with:
+ (void)cancelPreviousPerformRequestsWithTarget:(id)aTarget selector:(SEL)aSelector object:(id)anArgument
which you will need to do if you want your object to be deallocated as performSelector retains both your object and the withObject parameter.