I've been struggling with CoreData
for a few days, but I keep getting this error:
'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name.
I have checked the entity name and what I wrote on my code and they're the same. I also recreated the object data-model and even delete the app from the simulator but nothing seems to fix it. Here's what I have:
method to save into CoreData:
-(IBAction)save:(id)sender {
NSManagedObject * newNews = [NSEntityDescription insertNewObjectForEntityForName:@"NewsStand"
inManagedObjectContext:coredata.managedObjectContext];
[newNews setValue:news_title forKey:@"story_title"];
[newNews setValue:news_desc forKey:@"story_desc"];
[newNews setValue:news_image forKey:@"story_image"];
[newNews setValue:test forKey:@"story_url"];
[coredata commit];
NSLog(@"data saved!!!!");
}
I have implemented all methods of core data in a separated class:
applicationDocumentsDirectory,
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator,
- (NSManagedObjectModel *)managedObjectModel,
- (NSManagedObjectContext *)managedObjectContext