views:

14

answers:

1

I created a entity called photo inmy .xcdatamodel.

but when I tried to add it into my context:

NSManagedObjectContext *context = [self managedObjectContext];
Photo *p = [NSEntityDescription insertNewObjectForEntityForName:@"Photo" inManagedObjectContext:context];

it had run-time error:

+entityForName: could not locate an NSManagedObjectModel for entity name 'Photo'

it's really weird, I included the Photo.h, generated by xcode coredata.

does anyone have an idea why it goes wrong?

I can't find what's wrong at all.. > <

Thanks!

+2  A: 

Make sure your call to [self managedObjectContext] is returning a valid context (and not nil). Also make sure you're using the proper case (you said your entity was called "photo" but you're trying to insert a new object for an entity named "Photo").

Joshua Nozzi
Thank you so much! The context is nil.. Q QI really forget to check this!
Frost
The debugger is your friend. Buy it chocolate. Tell it you love it. :-)
Joshua Nozzi