0

I need to cancel UILocalNotification by Function but if i use

[[UIApplication sharedApplication] cancelAllLocalNotifications];

i get to the app again but the app stuck , it's timer

UILocalNotification *local = [[UILocalNotification alloc] init];
    local.fireDate = [NSDate dateWithTimeIntervalSinceNow:10];
    local.timeZone = [NSTimeZone defaultTimeZone];
    local.alertBody = @"";
    local.alertAction = @"";
    NSDictionary *customInfo =
    [NSDictionary dictionaryWithObject:@"ABCD1234" forKey:@"yourKey"];
    local.userInfo = customInfo;
    [[UIApplication sharedApplication] scheduleLocalNotification:local];
    [local release];


    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@""message:@""delegate: self cancelButtonTitle:@"Close"otherButtonTitles: nil];
    [alert show];
    [alert release];



    [self performSelector:@selector(myFunc) withObject:nil afterDelay:10.0];

    startDate = [[NSDate date]retain];

    // Create the stop watch timer that fires every 10 ms
    myTime = [NSTimer scheduledTimerWithTimeInterval:1.0/10.0
                                                      target:self
                                                    selector:@selector(updateTimer)
                                                    userInfo:nil
                                                     repeats:YES];
ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
jon
  • 1

1 Answers1

0

If by stuck you mean crash, then following the memory management rules you need to retain your timer. When there will be no need in timer anymore, invalidate and release it.

Evgeny Shurakov
  • 6,062
  • 2
  • 28
  • 22