Restkit编辑插入到coredata中 [英] Restkit edit inserting in coredata

查看:143
本文介绍了Restkit编辑插入到coredata中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用restkit消费web服务,但是当我得到数据我想添加一些其他参数,我搜索,我发现我应该实现函数调用willsave,但我不知道的方式

i use restkit to consume a web service ,, but when i get data i want to add some other parameters, i searched and i found that i should implement function called willsave but i don't know the way

NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:brandId,@"brandId",categoryId,@"categoryId", nil];

[[RKObjectManager sharedManager] postObject:nil path:@"/mywebservice" parameters:params success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {

    [self getProductsList];

} failure:^(RKObjectRequestOperation *operation, NSError *error) {

}];


推荐答案

您不需要使用 willSave ,这取决于你想做什么...

You don't need to use willSave, it depends what you want to do...

你可以使用成功 block,迭代 mappingResult 中提供的结果,进行更改,然后将主线程MOC保存到持久存储。

You can use the success block, iterate through the results provided in mappingResult, make changes and then save the main thread MOC to the persistent store.

willSave NSManagedObject 上的一个方法。所以,你将实现它在托管对象子类。这将导致更改被保存为映射过程的一部分,但它只对派生值/时间戳非常有用。

willSave is a method on NSManagedObject. So, you would implement it on the managed object subclasses. This will result in changes being saved as part of the mapping process, but it's only really useful for derived values / time-stamping.

这篇关于Restkit编辑插入到coredata中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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