Possible Duplicate:
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'
我认为这是因为链接。我该如何解决?
谢谢。
最佳答案
1) 在您的项目中添加 CoreData 框架。
2) #import <CoreData/CoreData.h>
在你的App_Prefix.pch
文件。请参阅this accepted answer to the same question
关于iphone - 如何将核心数据添加到现有项目中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13758782/