在應用程序我有自定義tableview(UITableView *tableView)
這在tableview中編輯的UIViewController &的子類是表現完美,但是當我在這個方法中刪除行tableview編輯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
}
}
時斷點變爲在該行
[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];
}
- (無效)deleteRow:(玩家*)文檔{
// ReferMeAppDelegate *的appDelegate = (ReferMeAppDelegate *)[[UIApplication sharedApplication]委託]; self.party = [PartyParser loadParty]; (_party!= nil){(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]; 如果(resultName == 0 & & resultEmail == 0 & & resultPhone == 0 & & resultLocation == 0){ //lblName1.text = @ 「相等」; Player * playerr = [[Player alloc] init]; playerr = player; [_party.players removeObject:playerr]; // [_party.players removeObjectAtIndex:path.row]; 休息; } //} //if([player.email長度] == 0 & & player.alert == @ 「2」){ 否則{ resultName = [doc.name比較:player.name]; resultPhone = [doc.phone compare:player.phone]; 如果(resultName == 0 & & resultPhone == 0){* playerr = [[Player alloc] init]; playerr = player; [_party.players removeObject:playerr]; 休息;
}} }
for (Player *player in _party.players) {
NSLog(@"after match case player names");
NSLog(@"%@", player.name);
}
[PartyParser saveParty:_party];
}
}
我使用的GData XML的支持讀&寫操作的應用程序。
什麼控制檯上的崩潰日誌? – Swastik 2010-12-09 08:11:32
***由於未捕獲的異常'NSInternalInconsistencyException'而終止應用程序,原因:'無效的更新:節0中的行數無效。更新(1)後現有節中包含的行數必須等於在更新(1)之前包含在該部分中的行,加上或減去從該部分插入或刪除的行數(0插入,1刪除)。' 2010-12-09 14:04:01.478 ReferMe [29684:207] Stack: – 2010-12-09 08:36:29