如何修复此代码,我尝试在索引0处添加另一个单元格但是有异常日志显示
更新后的现有部分中包含的行数(10)必须等于更新前该部分中包含的行数(10)
if([fetchedresult count]>1) {
for (int i=0; i<[fetchedresult count]; i++) {
dataDict = [fetchedresult objectAtIndex:i];
//Some Code to fill commentResult
commentResult = [NSMutableDictionary dictionaryWithObjectsAndKeys:idUserComment,[fieldName ID],image,[fieldName PHOTO],username,[fieldName USERNAME],body,[fieldName BODYCOMMENT],createdAt,[fieldName CREATEDAT], nil];
[tblComment beginUpdates];
NSArray *indexPathArray = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:0]];
NSArray *lastArray = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:9 inSection:0]];
[tblComment deleteRowsAtIndexPaths:lastArray withRowAnimation:UITableViewRowAnimationFade];
[dataCommentField insertObject:commentResult atIndex:0];
[tblComment reloadRowsAtIndexPaths:indexPathArray withRowAnimation:UITableViewRowAnimationNone];
[tblComment endUpdates];
}
}
}