最小化应用程序时,一切都很好,但是当我尝试部署繁荣时,此错误 * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[__NSArrayM insertObject:atIndex:]: object cannot be nil '
-(void) applicationDidEnterBackground:(UIApplication *)application
{
NSDate *alertTime = [[NSDate date] dateByAddingTimeInterval:5];
UIApplication* app = [[UIApplication sharedApplication] init];
UILocalNotification* notifyAlarm = [[UILocalNotification alloc] init];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:kAllNews]];
NSError *error = nil;
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&error];
NSError *jsonParsingError = nil;
sortArray = [NSJSONSerialization JSONObjectWithData:response options:0 error:&jsonParsingError];
if (notifyAlarm)
{
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"news"])
{
newsNew = [NSMutableArray arrayWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:@"news"]];
}
if (newsNew.count > sortArray.count) {
notifyAlarm.fireDate = alertTime;
notifyAlarm.timeZone = [NSTimeZone defaultTimeZone];
notifyAlarm.repeatInterval = 0;
notifyAlarm.soundName = @"Glass.aiff";
notifyAlarm.alertAction = @"Gipoteza";
notifyAlarm.alertBody = @"Добавлена новая новость";
[app scheduleLocalNotification:notifyAlarm];
}
}
}