Objective c 数据核异常

Objective c 数据核异常,objective-c,core-data,ios7,nsexception,Objective C,Core Data,Ios7,Nsexception,我不知道我的问题在哪里,因为实体“Utente”存在 错误代码: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+entityForName: nil is not a legal NSManagedObjectContext parameter searching for entity name 'Utente'' *** First throw call stack:

我不知道我的问题在哪里,因为实体“Utente”存在

错误代码:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+entityForName: nil is not a legal NSManagedObjectContext parameter searching for entity name 'Utente'' *** First throw call stack: ( 0 CoreFoundation 0x0000000101bf0495 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x00000001016f099e objc_exception_throw + 43 2 CoreData 0x0000000101e76599 +[NSEntityDescription entityForName:inManagedObjectContext:] + 217 3 CoreData 0x0000000101eb2e7e +[NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext:] + 30 4 VucmpraJson 0x000000010000514b -[LoginViewController login:] + 4843 5 UIKit 0x000000010029ef06 -[UIApplication sendAction:to:from:forEvent:] + 80 6 UIKit 0x000000010029eeb4 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 17 7 UIKit 0x000000010037b880 -[UIControl _sendActionsForEvents:withEvent:] + 203 8 UIKit 0x000000010037adc0 -[UIControl touchesEnded:withEvent:] + 530 9 UIKit 0x00000001002d5d05 -[UIWindow _sendTouchesForEvent:] + 701 10 UIKit 0x00000001002d66e4 -[UIWindow sendEvent:] + 925 11 UIKit 0x00000001002ae29a -[UIApplication sendEvent:] + 211 12 UIKit 0x000000010029baed _UIApplicationHandleEventQueue + 9579 13 CoreFoundation 0x0000000101b7fd21 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 14 CoreFoundation 0x0000000101b7f5f2 __CFRunLoopDoSources0 + 242 15 CoreFoundation 0x0000000101b9b46f __CFRunLoopRun + 767 16 CoreFoundation 0x0000000101b9ad83 CFRunLoopRunSpecific + 467 17 GraphicsServices 0x00000001040d0f04 GSEventRunModal + 161 18 UIKit 0x000000010029de33 UIApplicationMain + 1010 19 VucmpraJson 0x0000000100021d13 main + 115 20 libdyld.dylib 0x00000001025f15fd start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException 。 .

实体:上尉

属性:电子邮件;密码

太多人了

nil不是搜索实体名称“Utente”的合法NSManagedObjectContext参数

意味着您的托管对象上下文为零。检查
self.managedObjectContext
分配

编辑


怎么能检查这个??sry但这是我第一次生成核心数据在显示LoginViewController之前,您是否已将该值分配给managedObjectContext?设置在哪里
managedObjectContext
@property (nonatomic,strong) NSManagedObjectContext* managedObjectContext;
    NSManagedObjectContext *context = [self managedObjectContext];
NSManagedObject * Utente = [NSEntityDescription          insertNewObjectForEntityForName:@"Utente" inManagedObjectContext:context];
[Utente setValue: emailText.text forKey:@"email"];
NSError *error;
    //[context save:&error];
  if (![context save:&error]) {
    NSLog(@"Whoops, couldn't save: %@", [error localizedDescription]);
}
if (! [self managedObjectContext]) {
    NSLog(@"You will receive your exception");
} else {
    // Insert new entity into specified context
}