in app i have custom tableview(UITableView *tableView)
which subclass of uiviewcontroller & in tableview editing is show perfectly but when i delete row
- (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
}
}
in this method when breakpoint goes at that line
[tableView deleteRowsAtIndexPaths: [NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
my application crash what i do for come out from it.
-(void)testing:(NSIndexPath *)path{
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]delegate];
self.party = [PartyParser loadParty];
if (_party != nil) {
for (Player *player in _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 = [doc.name compare:player.name];
resultEmail = [doc.email compare:player.email];
resultPhone = [doc.phone compare:player.phone];
resultLocation = [doc.location compare:player.location];
if(resultName == 0 && resultEmail == 0 && resultPhone == 0 && resultLocation == 0){
//lblName1.text = @"equal";
Player *playerr = [[Player alloc]init];
playerr = player;
[_party.players removeObject:playerr];
//[_party.players removeObjectAtIndex:path.row];
break;
}
// }
//if([player.email length] == 0 && player.alert == @"2"){
else{
resultName = [doc.name compare:player.name];
resultPhone = [doc.phone compare:player.phone];
if (resultName == 0 && resultPhone == 0) {
Player *playerr = [[Player alloc]init];
playerr = player;
[_party.players removeObject:playerr];
break;
}
}
}
for (Player *player in _party.players) {
NSLog(@"after match case player names");
NSLog(@"%@", player.name);
}
[PartyParser saveParty:_party];
}
}
I'm using GData xml in app which support read & write operations.