2011-09-08 80 views
0

我需要通過功能取消UILocalNotification但如果我使用我需要停止或取消UILocalNotification

[[UIApplication sharedApplication] cancelAllLocalNotifications]; 

我到應用程序再次,但應用程序卡住,它的計時器

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]; 

回答

0

如果卡住你的意思是崩潰,然後遵循內存管理規則,你需要保留你的計時器。 當計時器中不再需要時,使其失效並釋放它。