Я пытаюсь использовать предоставленную Apple функцию «Редактировать» -> (-) -> «Удалить», чтобы удалить строку из моего UITableView.
У меня здесь активирована кнопка:
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
UITableViewCell, созданный здесь:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
PositionCell *cell = (PositionCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[PositionCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
FSExAppDelegate *appDelegate = (FSExAppDelegate *)[[UIApplication sharedApplication] delegate];
Position *pos = [appDelegate.positions objectAtIndex:indexPath.row];
[cell setPosition:pos];
// Configure the cell.
return cell;
}
А потом только Apple предоставила код:
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source.
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
}
}
Когда я выполняю действие удаления, я застреваю в:
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
с "Потоком 1: запрограммировать полученный сигнал 'SIGABRT'".
Я тратил вопросы здесь, но, похоже, ничего не могу найти для этой проблемы. Кто-нибудь может помочь?
DJS.