в приложении у меня есть пользовательский tableview(UITableView *tableView)
, который подкласс uiviewcontroller & в редактировании табличного представления отображается отлично, но когда я удаляю строку
- (void)tableView:(UITableView *)tableView1 commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
//[appDelegate deleteItemAtIndexPath:indexPath];
[self testing:indexPath];
[tableView deleteRowsAtIndexPaths:
[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationFade];//in this line app crash
NSLog(@"delete row");
[tableView reloadData];
}
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
//nothing to do item already added
}
}
в этом методе, когда точка останова идет в этой строке
[tableView deleteRowsAtIndexPaths: [NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
из-за этого выходит из строя мое приложение.
- (пустое) тестирование: (NSIndexPath *) путь {
Player *doc = [[Player alloc]init];
NSMutableArray* reversedArray = [[NSMutableArray alloc] initWithArray:[[[[NSArray alloc] initWithArray: _data] reverseObjectEnumerator] allObjects]];
doc = [reversedArray objectAtIndex:path.row];
NSLog(@"%@,%d", doc.name,path.row);
[self deleteRow:doc];
}
- (void) deleteRow: (Player *) doc {
// ReferMeAppDelegate * appDelegate = (ReferMeAppDelegate *) [[UIApplication sharedApplication] делегат];
self.party = [PartyParser loadParty];
if (_party! = nil) {
для (Player * player в _party.players) {
NSLog (@ "% @,% @", player.name, player.alert);
NSComparisonResult resultName, resultEmail, resultPhone, resultLocation;
// NSString * str = [appDelegate.plistDict valueForKey: @ "flag"];
// if ([player.email length]! = 0 && player.alert == @ "1") {
resultName = [имя документа сравнивать: имя игрока];
resultEmail = [doc.email сравнить: player.email];
resultPhone = [doc.phone Сравнение: player.phone];
resultLocation = [doc.location Compare: player.location];
if (resultName == 0 && resultEmail == 0 && resultPhone == 0 && resultLocation == 0) {
//lblName1.text = @ "равный";
Player * playerr = [[Player alloc] init];
playerr = игрок;
[_party.players removeObject: playerr];
//[_party.players removeObjectAtIndex: path.row];
перерыв;
}
//}
//if([player.email length] == 0 && player.alert == @ "2") {
еще {
resultName = [имя документа сравнивать: имя игрока];
resultPhone = [doc.phone Сравнение: player.phone];
if (resultName == 0 && resultPhone == 0) {
Player * playerr = [[Player alloc] init];
playerr = игрок;
[_party.players removeObject: playerr];
перерыв;
}
}
}
for (Player *player in _party.players) {
NSLog(@"after match case player names");
NSLog(@"%@", player.name);
}
[PartyParser saveParty:_party];
}
} * * тысяча двадцать-один
Я использую GData xml в приложении, которое поддерживает операции чтения и записи.