我想将核心数据添加到现有的iPhone项目中,但我仍然遇到很多编译错误:- NSManagedObjectContext undeclared - Expected specifier-qualifier-list before 'NSManagedObjectModel' - ...我已经将核心数据框架添加到目标(右键单击我的项目“Targets”,“Add” - “Existing Frameworks”,“CoreData.framework”)。我的头文件:NSManagedObjectModel *managedObjectModel;NSManagedObjectContext *managedObjectContext; NSPersistentStoreCoordinator *persistentStoreCoordinator;[...]@property (nonatomic, retain, readonly) NSManagedObjectModel *managedObjectModel;@property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext;@property (nonatomic, retain, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;我错过了什么?开始一个新项目不是一个选择......非常感谢!编辑 对不起,我确实有这些实现...但似乎缺少库...实现方法已满,编译错误如“ managedObjectContext undeclared”,“ NSPersistentStoreCoordinator undeclared”,但也有“预期”)'之前NSManagedObjectContext“(虽然它似乎括号是正确的)...#pragma mark -#pragma mark Core Data stack/** Returns the managed object context for the application. If the context doesn't already exist, it is created and bound to the persistent store coordinator for the application. */- (NSManagedObjectContext *) managedObjectContext { if (managedObjectContext != nil) { return managedObjectContext; } NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; if (coordinator != nil) { managedObjectContext = [[NSManagedObjectContext alloc] init]; [managedObjectContext setPersistentStoreCoordinator: coordinator]; } return managedObjectContext;}/** Returns the managed object model for the application. If the model doesn't already exist, it is created by merging all of the models found in application bundle. */- (NSManagedObjectModel *)managedObjectModel { if (managedObjectModel != nil) { return managedObjectModel; } managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles:nil] retain]; return managedObjectModel;}
3 回答
- 3 回答
- 0 关注
- 543 浏览
添加回答
举报
0/150
提交
取消