RestKit multiple RKObjectManagers object mapping

僤鯓⒐⒋嵵緔 提交于 2019-12-11 07:36:46

问题


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"]];

I get the following error:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '[RKObjectManager sharedManager].objectStore cannot be nil'

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];

}

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)


回答1:


You are trying to use a shared RKObjectManager for managed (coredata) and unmanaged models. You have to set objectStore property for that RKObjectManager.

I think you can use two RKObjectManagers separately, just create them using initWithBaseURL



来源:https://stackoverflow.com/questions/9278156/restkit-multiple-rkobjectmanagers-object-mapping

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!