Objective C Timer

Thursday, January 1, 2009

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

1-(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]; } 

Other posts

Tagged with: