SIGABRT when trying to add atributes in entity. Core Data on iOs

713 Views Asked by At

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];
2

There are 2 best solutions below

1
On BEST ANSWER

Most likely context is nil. Pass a nil managed object context value will usually cause a crash. Confirm that you have a value in context before passing it to the method.

Check the entity name as well.

0
On

Problem was in my DataManager singleton, sorry for wasting your time.