POST请求后删除CoreData对象 [英] Delete CoreData objects after POST request

查看:192
本文介绍了POST请求后删除CoreData对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用RestKit 0.20.3与CoreData来缓存我的Web服务的结果。
我需要从CoreData中删除不在响应中的所有对象,因此我使用 [RKObjectManager addFetchRequestBlock] 。一切工作正常,当我做GET请求,但当我做POST请求对象不会删除CoreData,我认为因为 deleteLocalObjectsMissingFromMappingResult 仅完成GET请求。

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.

我理解,在RESTfull架构中,POST请求用于更新服务器端的实体,但在我的情况下,Web服务提供搜索功能,并需要大量可选参数POST。

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.

是否有一种方法来配置RestKit,即使在POST请求之后也要进行删除?

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

推荐答案

这是目前的不支持。这里最好的选择是在 RKManagedObjectRequestOperation 中添加一个 RKRequestMethod 属性,指定允许用于管理对象清理。这将是一个简单的更改实现。

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.

请在RestKit Github上打开一个问题,请求该功能,我们将看到将其包含在0.21.0中。

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

这篇关于POST请求后删除CoreData对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆