【发布时间】:2009-08-18 12:11:41
【问题描述】:
我有一个使用 Core Data 处理请求的 iPhone 3.0 应用程序。它有一个按请求状态(sectionNameKeyPath:@"status")分组的所有请求的视图。它还有另一个视图,用户可以在其中更改请求状态。
当特定组中有一行/请求并且用户编辑该请求的状态(因此该行所属的部分应该消失)时,我遇到了问题,以下代码引发了异常:
//Change the request status. Request is the NSManagedObject
request.status = [NSNumber numberWithInt:Responded];
// Save the context.
NSError *error;
//The exception is raised at the following line
if (![request.managedObjectContext save:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort(); // Fail
}
异常文本如下: 2009-08-18 15:04:55.866 应用程序 [263:20b] *** 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无效更新:第 0 节中的行数无效。包含在更新后的现有节 (8) 必须等于更新前该节中包含的行数 (1),加上或减去从该节插入或删除的行数(0 插入,0 删除)。
谁能解释为什么我有这个异常以及如何处理它?
【问题讨论】:
标签: iphone objective-c uitableview core-data