0

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];
stalk
  • 97
  • 7

2 Answers2

0

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.

TechZen
  • 64,370
  • 15
  • 118
  • 145
-3

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

stalk
  • 97
  • 7