Objective C Timer

This is a simple timer, you may need to declare some variables in the .h file.

-(void)onViewDidLoad {
//set on start up
NSDate *startTime = [NSDate date]; 
-(void)someOtherFunction {
//amount to dely by (seconds)
NSInteger *delayAmount = 1;
//work out the current delay time
NSTimeInterval elapsedTime = [startTime timeIntervalSinceNow]; 
//if the delay is bigger than the specified amount then...
if (elapsedTime >= delayAmount) {
//Do the stuff to do when the delay time has passed
NSDate *startTime = [NSDate date]; 
Published on

Filled under


comments powered by Disqus