嗨,我正在创建一个应用程序,该应用程序需要将我的标签内容中的数据保存到我的核心数据模型中,该模型名为 cart.xcdatamodeld,我的实体名为 Cartdetail。当我在应用程序中按下保存按钮时,出现以下错误...
- (void)viewDidLoad {
if (managedObjectContext == nil) {
managedObjectContext = [(AppDelegate *)[[UIApplication sharedApplication] delegate]managedObjectContext];
}
}
- (IBAction)SaveTest:(id)sender {
ViewController2 *second = (ViewController2 *)[NSEntityDescription insertNewObjectForEntityForName:@"Cartdetail" inManagedObjectContext:managedObjectContext];
}
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'Cartdetail''
*** Call stack at first throw:
(
0 CoreFoundation 0x010265a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x01444313 objc_exception_throw + 44
2 CoreData 0x00036ebb +[NSEntityDescription entityForName:inManagedObjectContext:] + 187
3 CoreData 0x0006e9eb +[NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext:] + 59
4 tablevc 0x00009c97 -[Description alertView:clickedButtonAtIndex:] + 519
5 UIKit 0x00621c5f -[UIAlertView(Private) _buttonClicked:] + 296
6 UIKit 0x002784fd -[UIApplication sendAction:to:from:forEvent:] + 119
7 UIKit 0x00308799 -[UIControl sendAction:to:forEvent:] + 67
8 UIKit 0x0030ac2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
9 UIKit 0x003097d8 -[UIControl touchesEnded:withEvent:] + 458
10 UIKit 0x0029cded -[UIWindow _sendTouchesForEvent:] + 567
11 UIKit 0x0027dc37 -[UIApplication sendEvent:] + 447
12 UIKit 0x00282f2e _UIApplicationHandleEvent + 7576
13 GraphicsServices 0x01c34992 PurpleEventCallback + 1550
14 CoreFoundation 0x01007944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
15 CoreFoundation 0x00f67cf7 __CFRunLoopDoSource1 + 215
16 CoreFoundation 0x00f64f83 __CFRunLoopRun + 979
17 CoreFoundation 0x00f64840 CFRunLoopRunSpecific + 208
18 CoreFoundation 0x00f64761 CFRunLoopRunInMode + 97
19 GraphicsServices 0x01c331c4 GSEventRunModal + 217
20 GraphicsServices 0x01c33289 GSEventRun + 115
21 UIKit 0x00286c93 UIApplicationMain + 1160
22 tablevc 0x00001d4a main + 170
23 tablevc 0x00001c95 start + 53
)
terminate called throwing an exception
我是iOS新手..请帮助我..谢谢..