3
可能重複:
Adding Core Data to existing iPhone project如何將核心數據添加到現有項目?
與出選擇coreData起初,我已經創建的項目。經過一段時間的發展,我想使用核心數據進行數據管理。它給像
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'
我想這是因爲連接的某些例外。我該如何解決它?
謝謝。
您可以分享您的代碼以創建持久性存儲協調員,managedobjectmodel和managedobjectcontext –
@SunilPandey:context = [[NSManagedObjectContext alloc] init]; CDAlbum * albumInfo = [NSEntityDescription insertNewObjectForEntityForName:@「CDAlbum」 inManagedObjectContext:context]; albumInfo.albumName = @「MyAlbum」; CDPage * pageInfo = [NSEntityDescription insertNewObjectForEntityForName:@「CDPage」 inManagedObjectContext:context]; pageInfo.message = @「這是我的信息」; pageInfo.pageId = @「123456」; pageInfo.album = albumInfo; albumInfo.page = pageInfo; – user1244311
我想你應該學習核心數據的一些基本概念。 http://www.raywenderlich.com/934/core-data-on-ios-5-tutorial-getting-started勾選此項 –