【发布时间】:2011-11-29 03:13:33
【问题描述】:
我在这里经历了很多问题,但仍然不清楚。
我的应用程序(标签栏应用程序)中有 5 个选项卡,每个选项卡负责将一些细节推送到 1 个表中。所以实际上每个选项卡都有一个表。
我正确初始化了managedObjectContext,并成功地将数据保存在实体中。现在,当我尝试将数据推送到第二个表中时,我得到了这个异常:
由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“+entityForName:找不到实体名称“OtherDetail”的 NSManagedObjectModel*
是否需要一次性将数据推送到所有实体中?
(void)persistOtherDetail:segCtrlValue:genInfoId:type:labelValue{
NSLog(@"Persisting %@",type);
NSLog(@"seg control value %@", segCtrlValue);
OtherDetail *otherDetail = (OtherDetail *)[NSEntityDescription insertNewObjectForEntityForName:@"OtherDetail" inManagedObjectContext:managedObjectContext];
otherDetail.enteredValue = segCtrlValue;
otherDetail.genInfoId = genInfoId;
otherDetail.checklistDesc = labelValue;
otherDetail.checklistName = type;
NSError *error;
if (![managedObjectContext save:&error])
{
NSLog(@"Problem saving: %@", [error localizedDescription]);
}
}
【问题讨论】:
-
您能否将尝试将数据持久化到“OtherDetail”的代码部分发布?
-
你的方法签名伤了我的眼睛
-
@VinceBurn 你在谈论争论吗?我需要一个可以传递这 4 个参数的方法,因为我需要从不同的选项卡一次又一次地调用它。
-
是的,这不是参数的数量,而是它们都被挤压并且看起来好像缺少某些部分的事实
- (void)persistOtherDetail:(int)segCtrlValue genInfoId:(int)anId withChecklistType:(int)aType forLabelValue:(NSString *)theLabelTxt也许我是那些纯粹主义者并且弄错了那个,但是我喜欢它在 Apple 框架中的完成方式,每种方法都在讲述一个故事。
标签: ios objective-c iphone cocoa-touch core-data