问题
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:
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.
来源:https://stackoverflow.com/questions/18655414/delete-coredata-objects-after-post-request