2011-09-08 81 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

如果卡住你的意思是崩溃,然后遵循内存管理规则,你需要保留你的计时器。 当计时器中不再需要时,使其失效并释放它。