這是奇怪。我的應用程序會在本地通知發送到後臺時安排本地通知,並且在第一次通知正確顯示時,只要後面的通知被觸發,整個應用程序就會崩潰。是的,在後臺。雖然沒有代碼正在執行。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