Restkit edit inserting in coredata

五迷三道 提交于 2019-12-13 02:57:42

问题


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) {

}];

回答1:


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

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 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.



来源:https://stackoverflow.com/questions/22388350/restkit-edit-inserting-in-coredata

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