2010-12-09 39 views
0

dans l'application i ont coutume tableview(UITableView *tableView) qui sous-classe de UIViewController & dans l'édition tableview est montre parfaitement, mais quand je supprimer la ligneapplication de crash de tableview édition dans l'iphone?

- (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 
    } 
} 

dans cette méthode lorsque breakpoint va à cette ligne

[tableView deleteRowsAtIndexPaths: [NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; 

mon plantage de l'application ce que je fais pour en sortir.

- (void) test: chemin (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: (joueur *) {doc

// ReferMeAppDelegate * appDelegate = (ReferMeAppDelegate *) [[délégué UIApplication sharedApplication]]; self.party = [PartyParser loadParty]; if (_party! = Nil) { pour (joueur * joueur dans _party.players) { NSLog (@ "% @,% @", player.name, player.alert); NSComparisonResult resultName, resultEmail, resultPhone, resultLocation; // NSString * str = [appDelegate.plistDict valueForKey: @ "flag"]; // if ([longueur du lecteur]! = 0 & & player.alert == @ "1") { resultName = [nom.du.domaine: player.name]; Resultatmail = [comparez doc.email: player.email]; resultPhone = [Comparer avec doc.phone: player.phone]; resultLocation = [emplacement doc.location: player.location]; if (0 == ResultName & & resultEmail == 0 & & resultPhone == 0 & & resultLocation == 0) { //lblName1.text = @ "égal"; Joueur * playerr = [[Player alloc] init]; playerr = joueur; [_party.players removeObject: playerr]; //[_party.players removeObjectAtIndex: path.row]; pause; } //} longueur de //if([player.email] de == 0 & & de player.alert == @ "2") {{ autre ResultName = [doc.name comparer: player.name]; resultPhone = [Comparer avec doc.phone: player.phone]; if (resultName == 0 & & resultPhone == 0) { Joueur * playerr = [[Player alloc] init]; playerr = joueur; [_party.players removeObject: playerr]; pause;
}} }

 for (Player *player in _party.players) { 
      NSLog(@"after match case player names"); 
      NSLog(@"%@", player.name); 
     } 
     [PartyParser saveParty:_party]; 
    } 

}

J'utilise xml GData dans l'application qui prennent en charge lecture & opérations d'écriture.

+0

ce est le journal de l'accident sur la console? – Swastik

+0

*** Terminaison de l'application due à l'exception non interceptée 'NSInternalInconsistencyException', raison: 'Invalid update: nombre de lignes incorrect dans la section 0. Le nombre de lignes contenues dans une section existante après la mise à jour (1) doit être égal au lignes contenues dans cette section avant la mise à jour (1), plus ou moins le nombre de lignes insérées ou supprimées de cette section (0 inséré, 1 supprimé). ' 2010-12-09 14: 04: 01.478 ReferMe [29684: 207] Stack: –

Répondre

0

méthode deleteRowsAtIndexPaths: effectue seul effet visuel de suppression, vous devez également supprimer manuellement élément correspondant de votre source de données pour nombre d'éléments qu'il sera conforme à ce qui est attendu de votre opération, par exemple:

//You need to remove item from data source 
[yourMutableDataArray removeObjectAtIndex:indexPath.row]; 
// Tell table view to remove the corresponding item cell 
[tableView deleteRowsAtIndexPaths: 
      [NSArray arrayWithObject:indexPath] 
      withRowAnimation:UITableViewRowAnimationFade];//in this line app crash 
NSLog(@"delete row"); 
//[tableView reloadData]; // You do not need this line 
+0

j'ai édité ma question je supprime des données de ligne dans le xml mais il génère même accident –

+0

s'il vous plaît formater votre code - il est absolument illisible – Vladimir

+0

Salut, iOS_User u eu une solution. Maintenant, je suis confronté au même problème des 2 derniers jours. Je ne peux pas résoudre celui-ci. Pouvez-vous s'il vous plaît m'aider? –