1
votes

I'm using RestKit 0.20.3 with CoreData to cache the results from my web services. I need to delete from CoreData all the objects that are not in the response so I use [RKObjectManager addFetchRequestBlock]. Everything works fine when I do GET requests but when I do POST requests the objects are not deleted in CoreData, I think because deleteLocalObjectsMissingFromMappingResult is done only with GET requests.

I understand that, in a RESTfull architecture, POST requests are used to update an entity on the server side but in my case the web service provides search capabilities and takes a lot of optional parameters in POST.

Is there a way to configure RestKit to do the deletion even after POST requests?

If not, do I need to perform the deletion by hand at the end of each request or is there another better way?

1
You debugged to see deleteLocalObjectsMissingFromMappingResult isn't called? I expect it should be called as it's part of the mapping operation. - Wain
the body of deleteLocalObjectsMissingFromMappingResult contains the following code witch cause a return without any delete in case of non GET request if (! [[self.HTTPRequestOperation.request.HTTPMethod uppercaseString] isEqualToString:@"GET"]) { RKLogDebug(@"Skipping deletion of orphaned objects: only performed for GET requests."); return YES; } - user676532
Cleanest option is to do the deletion yourself then. - Wain

1 Answers

1
votes

This currently is not supported. The best option here would be to add an RKRequestMethod property to RKManagedObjectRequestOperation that specifies the HTTP methods that are permitted for use with managed object cleanup. This would be a simple change to implement.

Please open up an issue on the RestKit Github requesting the feature and we'll see about getting it included in 0.21.0.