开发者

can't find managed object model?

开发者 https://www.devze.com 2023-01-04 10:27 出处:网络
I created a entity called photo inmy .xcdatamodel. but when I tried to add it into my context: NSManagedObjectContext *context = [self managedObjectContext];

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:

开发者_Go百科

+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!


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").

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号