这是奇怪。我的应用程序会在本地通知发送到后台时安排本地通知,并且在第一次通知正确显示时,只要后面的通知被触发,整个应用程序就会崩溃。是的,在后台。虽然没有代码正在执行。iPhone应用程序崩溃本地通知
没有给出控制台输出,我只是得到一个对话框,在iPhone模拟器中显示“模拟应用程序退出”。在实际的iPhone上,我被扔回跳板。
以下是通知的相关代码。谢谢你的帮助。
- (void)scheduleLocalNotificationsForAlarmsWithNextAlarmAt:(NSDate *)theFireDate ofType:(int)workPlayType {
BOOL backgroundSupported = NO;
UIDevice* device = [UIDevice currentDevice];
if ([device respondsToSelector:@selector(isMultitaskingSupported)])
backgroundSupported = device.multitaskingSupported;
if(!backgroundSupported) return;
int work_minutes = [[NSUserDefaults standardUserDefaults] integerForKey:@"work_minutes_preference"];
int play_minutes = [[NSUserDefaults standardUserDefaults] integerForKey:@"play_minutes_preference"];
int workPlayStatusForNotif = workPlayType;
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
if (workPlayStatusForNotif == 1) {
localNotif.alertBody = @"Work";
localNotif.repeatInterval = work_minutes;
} else {
localNotif.alertBody = @"Play";
localNotif.repeatInterval = play_minutes;
}
localNotif.fireDate = theFireDate;
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.alertAction = NSLocalizedString(@"View Details", nil);
localNotif.soundName = @"ding.caf";
localNotif.applicationIconBadgeNumber = 0;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
// now the other one
localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
if (workPlayStatusForNotif == 0) {
localNotif.alertBody = @"Work";
localNotif.fireDate = [theFireDate dateByAddingTimeInterval:(float)work_minutes*60];
localNotif.repeatInterval = work_minutes;
} else {
localNotif.alertBody = @"Play";
localNotif.fireDate = [theFireDate dateByAddingTimeInterval:(float)play_minutes*60];
localNotif.repeatInterval = play_minutes;
}
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.alertAction = NSLocalizedString(@"View Details", nil);
localNotif.soundName = @"ding.caf";
localNotif.applicationIconBadgeNumber = 0;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
}
用调试器进行堆栈跟踪。另外,你会得到什么样的退出状态? – geon 2010-09-16 09:55:53
看起来很愚蠢,但是,我该怎么做?当应用程序进入后台时,似乎所有的调试输出都会停止。 – winsmith 2010-09-20 09:35:34
@winsmith你有调试吗?你为SIGABRT得到了什么? – 2014-03-26 11:47:22