2014-09-10 2 views
-1

Я не знаю, где моя проблема, потому что существует сущность «Utente».Data-core NSException

Код ошибки:

 
*** 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 

Код:

@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]); 
} 

лица: Utente

атрибуты: адрес электронной почты, пароль

ТНХ к гораздо парням

+0

Где находится 'managedObjectContext'? – Larme

ответ

1

ноль не является юридическим параметром NSManagedObjectContext ищет имя объекта 'Utente'

означает, что ваш управляемый объект контекст равен нулю. Проверьте назначение self.managedObjectContext.

редактировать

if (! [self managedObjectContext]) { 
    NSLog(@"You will receive your exception"); 
} else { 
    // Insert new entity into specified context 
} 
+0

как это проверить? sry, но я первый раз делаю основные данные –

+0

Вы указали значение для managedObjectContext перед представлением своего LoginViewController? – voromax

+0

нет, .... почему? ... –