3

Possible Duplicate:
Adding Core Data to existing iPhone project

Initially i have created project with out selecting coreData. After some point of development i want to use core data for data management. It's giving some exception like

context = [[NSManagedObjectContext alloc] init]; 
CDAlbum *albumInfo = [NSEntityDescription insertNewObjectForEntityForName:@"CDAlbum" inManagedObjectContext:context]; 
albumInfo.albumName = @"MyAlbum"; 
CDPage *pageInfo = [NSEntityDescription insertNewObjectForEntityForName:@"CDPage" inManagedObjectContext:context]; 
pageInfo.message = @"It's my message"; 
pageInfo.pageId = @"123456"; 
pageInfo.album = albumInfo;
albumInfo.page = pageInfo;

'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'CDAlbum'

I think this is because of linking. How can I resolve it?

Thanks.

Community
  • 1
  • 1
user1244311
  • 191
  • 1
  • 2
  • 14
  • can you share your code for creating persistent store coordinator, managedobjectmodel and managedobjectcontext – Sunil Pandey Dec 07 '12 at 07:36
  • @SunilPandey : context = [[NSManagedObjectContext alloc] init]; CDAlbum *albumInfo = [NSEntityDescription insertNewObjectForEntityForName:@"CDAlbum" inManagedObjectContext:context]; albumInfo.albumName = @"MyAlbum"; CDPage *pageInfo = [NSEntityDescription insertNewObjectForEntityForName:@"CDPage" inManagedObjectContext:context]; pageInfo.message = @"It's my message"; pageInfo.pageId = @"123456"; pageInfo.album = albumInfo; albumInfo.page = pageInfo; – user1244311 Dec 07 '12 at 08:57
  • I think you should learn some basic concept of core Data. http://www.raywenderlich.com/934/core-data-on-ios-5-tutorial-getting-started check this – Sunil Pandey Dec 07 '12 at 09:01

1 Answers1

0

1) Add CoreData frame in your project. 2) #import <CoreData/CoreData.h> in your App_Prefix.pch file. See this accepted answer to the same question

Community
  • 1
  • 1
Atif Azad
  • 1,294
  • 1
  • 16
  • 30