я запланировать UILocalNotification
от моего UITableViewCell
подкласса:Ошибка при попытке отменить UILocalNotification
UILocalNotification *notification = [[UILocalNotification alloc] init];
[notification setFireDate:[NSDate dateWithTimeIntervalSinceNow:event.destinationTime]];
[notification setAlertBody:title];
[notification setTimeZone:[NSTimeZone defaultTimeZone]];
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
self.eventNotification = notification; // assigning to class property
И я стараюсь, чтобы отменить уведомление при удалении ячейки:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
CustomCell *cell = (CustomCell *) [self.tableView cellForRowAtIndexPath:indexPath];
[[UIApplication sharedApplication] cancelLocalNotification:cell.eventNotification];
}
Но когда я бегу , Я получаю следующую ошибку при удалении ячейки:
'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'
В чем проблема? Или я делаю это неправильно? Благодаря!
Тестируете в iOS8 + OR iOS7 и ниже? –
@YogeshSuthar iOS 8 – Eilon
Вы запросили разрешение на создание локального уведомления? Если нет, тогда вы должны сначала спросить, и если предоставили создать локальное уведомление. –