Showing posts with label cancel. Show all posts
Showing posts with label cancel. Show all posts

Cancel Local Notification

Cancel all local notifications with this code:
[[UIApplication sharedApplication] cancelAllLocalNotifications];

Cancel one local notification with this line of code:
[[UIApplication sharedApplication] cancelLocalNotification:theNotification];

Remove or Release NSTimer

iPhone SDK Tips & Tricks
-(void)startTimer {
 [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(timerFire:) userInfo:nil repeats:YES];  //Don't forget the colon after timerFire if it has an argument!! }  -(void)timerFire:(NSTimer*)theTimer {  //Do timer stuff here   if (shouldKillTimer) [theTimer invalidate]; }

OR

[self performSelector:@selector(timerFunction) withObject:nil afterDelay:timeInSeconds];
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(timerfunction) object:nil];