My app receive SIGABRT when i'm trying to add atributes to my Entity.
NSManagedObjectContext *context=[[HistoryDataManager sharedInstance] mainObjectContext];
NSEntityDescription * entityDescription = [NSEntityDescription entityForName:@"Request" inManagedObjectContext:context];
Request *request=[[[Request alloc] initWithEntity:entityDescription insertIntoManagedObjectContext:context] autorelease];
NSLog(@"request: %@", request);
request.requestText=string;
request.timeStamp=[NSDate date];
[context insertObject:request];
NSError * error;
if (![context save:&error]) {
NSLog(@"Saving error : %@", [error userInfo]);
}
I've got entity with name Request and context!=nil, but I've got SIGABRT message everytime at this place:
NSEntityDescription * entityDescription = [NSEntityDescription entityForName:@"Request" inManagedObjectContext:context];
Most likely
context
is nil. Pass a nil managed object context value will usually cause a crash. Confirm that you have a value incontext
before passing it to the method.Check the entity name as well.