Delete CoreData objects after POST request

点点圈 提交于 2019-12-11 05:14:25

问题


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

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