我需要停止或取消UILocalNotification

时间:2011-09-08 00:33:03

标签: iphone objective-c push-notification xcode3.2

我需要按功能取消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];

1 个答案:

答案 0 :(得分:0)

如果被卡住意味着崩溃,那么按照内存管理规则,您需要保留计时器。 当不再需要计时器时,使其无效并释放它。