SIG_ABRT для UITableViewCell delete - PullRequest
       3

SIG_ABRT для UITableViewCell delete

2 голосов
/ 25 марта 2011

Я пытаюсь использовать предоставленную 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.

Ответы [ 2 ]

2 голосов
/ 25 марта 2011

Я думаю, вы уходите:

[mutableArrayAsDataSource removeObjectAtIndex:[indexPath row]];

Это, вероятно, должно произойти перед вызовом deleteRowsAtIndexPaths.

0 голосов
/ 25 марта 2011
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

пожалуйста, измените это на ниже

[tableView deleteRowsAtIndexPaths:[urArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...