- (void)tableView:(UITableView *)tv commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath {
if(editingStyle == UITableViewCellEditingStyleDelete) {
//Get the object to delete from the array.
NSLog(@"%@",[[_arrayForTable valueForKey:@"IDS"] objectAtIndex:[indexPath row]]);
NSInteger myInteger = [[[_arrayForTable valueForKey:@"IDS"] objectAtIndex:[indexPath row]] integerValue];
NSNumber *selRow = [NSNumber numberWithInt:myInteger];
NSLog(@"%@",selRow);
[self removeCell:selRow]; // this is working perfectly it gets remove from database
//Delete the object from the table.
// app get crash here crash report is pested below
[self.table deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
- (void) removeCell:(NSNumber *)selRow{
NSLog(@"_arrayForTable%@",_arrayForTable);
NSInteger myInteger = [selRow integerValue];
[_arrayForTable removeObjectAtIndex:myInteger];
NSLog(@"_arrayForTable%@",_arrayForTable);
if(deleteStmt == nil) {
const char *sql = "delete from PersonNamesAndBirthDates where ID = ?";
NSLog(@"%s",sql);
if(sqlite3_prepare_v2(database1, sql, -1, &deleteStmt, NULL) != SQLITE_OK)
NSAssert1(0, @"Error while creating delete statement. '%s'", sqlite3_errmsg(database1));
}
NSLog(@"%d",myInteger);
//When binding parameters, index starts from 1 and not zero.
sqlite3_bind_int(deleteStmt, 1, myInteger);
if (SQLITE_DONE != sqlite3_step(deleteStmt))
NSAssert1(0, @"Error while deleting. '%s'", sqlite3_errmsg(database1));
sqlite3_reset(deleteStmt);
}
*在聲明失敗 - [UITableView的_endCellAnimationsWithContext:],2013年4月8日/SourceCache/UIKit_Sim/UIKit-1912.3/UITableView.m:1046 17:01 :13.069 birthdate reminder 2 [583:15803] *終止應用到期 未捕獲的異常'NSInternalInconsistencyException',原因: '無效的更新:無效的行數在第0部分中.行中包含的現有節更新(12)必須是 等於該部分中包含的行數 更新(12),加或減從 插入或刪除的行數(0插入,1刪除)以及加或減行數 移入或移出該部分的行數(0移入,0移入出)。」碰撞從表視圖除去細胞
請建議一些
我numberofrow方法如下
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return _arrayForTable.count;
}
應用程序不崩潰每次某個作品的某個時候崩潰
粘貼numnerOfRows方法 – 2013-04-08 11:34:34
確定馬諾哈爾加入 – 2013-04-08 11:38:29
我的猜測是,你對'removeCell假設:?',這是工作這個行可能會從你的數據庫中刪除,但是你有沒有檢查你的變量'_arrayForTable'?看起來,它仍然存在。 – fguchelaar 2013-04-08 11:52:31