tags:

views:

106

answers:

1

I'm trying to figure out why insertNewObjectForEntityForName is not working. I assume it's something to do with my data model but can't be sure. Xcode does not report any errors nor does it crash. All I get is the first log statement output to the console.

NSLog(@"Get here...");
Task *task = (Task *)[NSEntityDescription insertNewObjectForEntityForName:@"Task" inManagedObjectContext:insertionContext];
NSLog(@"but never get here...");

Any suggestions as to how I can work out what the problem is?

A: 

I assume an exception occurs in line 2. Try the following

@try
{
    NSLog(@"Get here...");
    Task *task = (Task *)[NSEntityDescription insertNewObjectForEntityForName:@"Task" inManagedObjectContext:insertionContext];
    NSLog(@"but never get here...");
}
@catch (NSException * e)
{
    NSLog(@"Exception: %@", e);
}
Martin Brugger
That turned up "Exception: +entityForName: could not locate an NSManagedObjectModel for entity name Task".So, it looks like that hasn't been set up - thanks.
Snow Crash