问题描述
我使用了两个 RKObjectManager,一个没有 RKManagedObjectStore(这是共享实例),另一个有.当我尝试像这样设置 RKManagedObjectStore 时:
I'm using two RKObjectManagers, one without an RKManagedObjectStore, (which is the shared instance) and one with. When I attempt to set the RKManagedObjectStore like so:
[self.storeBackedObjectManager setObjectStore:[RKManagedObjectStore objectStoreWithStoreFilename:@"conversations.sqlite"]];
我收到以下错误:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '[RKObjectManager sharedManager].objectStore cannot be nil'
似乎 RestKit 正在尝试访问 NSManagedObject+ActiveRecord.m
中的 sharedManager(它不使用对象存储)的对象存储:
It seems that RestKit is trying to access the objectstore of the sharedManager (which doesn't use an object store), in NSManagedObject+ActiveRecord.m
:
+ (NSManagedObjectContext*)managedObjectContext {
NSAssert([RKObjectManager sharedManager], @"[RKObjectManager sharedManager] cannot be nil");
NSAssert([RKObjectManager sharedManager].objectStore, @"[RKObjectManager sharedManager].objectStore cannot be nil");
return [[[RKObjectManager sharedManager] objectStore] managedObjectContext];
}
有什么方法可以将引用传递给我的第二个存储支持的 RKObjectManager 实例?(如果我临时将共享管理器设置为商店支持的实例,则此映射工作正常)
Is there any way to pass a reference to my second, store backed RKObjectManager instance? (This mapping works fine if I temporarily set the shared manager to the store backed instance)
推荐答案
您正尝试将共享的 RKObjectManager 用于托管(核心数据)和非托管模型.您必须为该 RKObjectManager 设置 objectStore 属性.
You are trying to use a shared RKObjectManager for managed (coredata) and unmanaged models. You have to set objectStore property for that RKObjectManager.
我认为您可以单独使用两个 RKObjectManager,只需使用 initWithBaseURL
I think you can use two RKObjectManagers separately, just create them using initWithBaseURL
这篇关于RestKit 多个 RKObjectManagers 对象映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!