Upgrading to RestKit 0.10.0

580 views
Skip to first unread message

Josh Brown

unread,
Apr 5, 2012, 11:19:53 AM4/5/12
to res...@googlegroups.com
I'm upgrading to RestKit 0.10.0 from 0.9.3 and found that RKManagedObjectCache has disappeared. Is there a similar class in 0.10.0? I found the following issue on GitHub but don't see how to use the new API: https://github.com/RestKit/RestKit/pull/532

Is there documentation for this somewhere? I'd like to upgrade but I'm stuck until I can find out what to do with my class that conforms to RKManagedObjectCache.

Thanks,
Josh

--
Josh Brown
iOS Developer
Roadfire Software




Lightforce

unread,
Apr 6, 2012, 6:13:32 AM4/6/12
to res...@googlegroups.com

Hi Josh

You should be able to activate the cache like this:

[RKObjectManager sharedManager].objectStore.cacheStrategy = [RKInMemoryManagedObjectCache new];

Greets

Jeff Arena

unread,
Apr 6, 2012, 8:54:17 AM4/6/12
to res...@googlegroups.com
Hey Josh,

You're looking for this method in RKObjectMappingProvider+CoreData.h, specifically the fetchRequestBlock param:

- (void)setObjectMapping:(RKObjectMappingDefinition *)objectMapping forResourcePathPattern:(NSString *)resourcePathPattern withFetchRequestBlock:(RKObjectMappingProviderFetchRequestBlock)fetchRequestBlock;

Instead of forcing you to maintain a concrete class with knowledge of all the resourcePaths and fetchRequests needed to process local deletes in your app, we've now broken this logic out such that it can be provided as a block to the mapping provider, along with the individual object mapping you've configured.

Hope this helps.

Thanks,
Jeff

Josh Brown

unread,
Apr 13, 2012, 1:09:02 PM4/13/12
to res...@googlegroups.com
Thanks for your response, Jeff. Previously, we were occasionally returning multiple NSFetchRequests for a single resource path. Is this no longer an option? It appears that the RKObjectMappingProviderFetchRequestBlock only returns a single NSFetchRequest, rather than an array of NSFetchRequests. Is there any way to return multiple NSFetchRequests?

Thanks,
Josh

Jochen Schöllig

unread,
Apr 13, 2012, 1:49:11 PM4/13/12
to res...@googlegroups.com
Hello,

sorry but for me it seems not that simple how I should use

- (void)setObjectMapping:(RKObjectMappingDefinition *)objectMapping forResourcePathPattern:(NSString *)resourcePathPattern withFetchRequestBlock:(RKObjectMappingProviderFetchRequestBlock)fetchRequestBlock;
that there are no more duplicates in my app. I was working with 0.9.4 and i didn't use the objectCache or something. But now i would like to solve the problem that the remote server is always the master. If there is a object deleted there it should be deleted in my App Core Data, too. 

Always when i use loadObjectsAtResourcePath this is the current status and this status should be exactly in my Core Data. 
How can i upgrade my 0.9.4 code? Please help me with that because i don't know if i should delete some older code or only put the new in and so on.

Thanks,
Jochen 

Jeff Arena

unread,
Apr 13, 2012, 1:57:34 PM4/13/12
to res...@googlegroups.com
There is no longer support for providing multiple fetchRequests for a single resource path. If your app depends on that support, you'll need to add it back and send along a pull request with your changes.

Joe Kramer

unread,
May 16, 2012, 5:19:02 AM5/16/12
to res...@googlegroups.com
I am looking for a way to deleted orphaned objects that are not on the remote server anymore. Seems like with current Master version 0.10 this functionality has changed a lot and all threads, articles and examples refer to API that is no longer there. 
This thread appears to be the only lead.

Previously there was RKManagedObjectCache.(BOOL)shouldDeleteOrphanedObject:(NSManagedObject *)managedObject

Now this class is gone and apparently there's only this method setObjectMapping: forResourcePathPattern: withFetchRequestBlock that is related to this?

Could you please explain how returning fetchRequestBlock can solve the problem of deleting orphans? What need to be returned in the block, maybe some example?

Thank you.

David Morton

unread,
Sep 20, 2012, 9:26:17 AM9/20/12
to res...@googlegroups.com
+1. 

This is driving me nuts.  I'm trying to upgrade our app, and am having a hell of a time trying to figure out how to get the local store to delete orphans. 

Every post I see is about trying to STOP RestKit from deleting orphans, and yet I can't for the life of me figure out how to get it to actually delete orphans. 

Ben Corlett

unread,
Oct 21, 2012, 7:47:48 PM10/21/12
to res...@googlegroups.com
@David, @Joe, any luck with this?

I'm also stuck deleting orphaned objects
Reply all
Reply to author
Forward
0 new messages