【发布时间】:2014-02-17 05:38:32
【问题描述】:
请原谅可能的菜鸟问题。我正在使用 Restkit 2.0 构建一个应用程序,但在实现核心数据功能时遇到了问题。在this tutorial 之后,我将以下代码添加到我的 AppViewController(所有其他视图控制器都扩展了此类)。
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationController.navigationBar.shadowImage = [UIImage new];
NSError *error = nil;
NSURL *modelURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Jumplytics" ofType:@"momd"]];
// NOTE: Due to an iOS 5 bug, the managed object model returned is immutable.
NSManagedObjectModel *managedObjectModel = [[[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL] mutableCopy];
RKManagedObjectStore *managedObjectStore = [[RKManagedObjectStore alloc] initWithManagedObjectModel:managedObjectModel];
// Initialize the Core Data stack
[managedObjectStore createPersistentStoreCoordinator];
NSPersistentStore __unused *persistentStore = [managedObjectStore addInMemoryPersistentStore:&error];
NSAssert(persistentStore, @"Failed to add persistent store: %@", error);
[managedObjectStore createManagedObjectContexts];
// Set the default store shared instance
[RKManagedObjectStore setDefaultStore:managedObjectStore];
// Override point for customization after application launch.
self.managedObjectContext = managedObjectStore.mainQueueManagedObjectContext;
}
我收到错误:
property managedObjectContext not found on object of type 'AppViewController'
我可以做些什么来解决这个问题?
【问题讨论】:
标签: ios core-data restkit restkit-0.20