
RKEntityMapPing *entityMapPing = [RKEntityMapPing mapPingForEntityForname:entityname inManagedobjectStore:managedobjectStore];[entityMapPing addAttributeMapPingsFromDictionary:dict];if (uniqKey != nil) { entityMapPing.IDentificationAttributes = @[ uniqKey ];}// Set MIME Type to JsONmanager.requestSerializationMIMEType = RKMIMETypeJsON;// register mapPings with the provIDer using a response descriptorRKResponseDescriptor *responseDescriptor =[RKResponseDescriptor responseDescriptorWithMapPing:entityMapPing method:RKRequestMethodPOST pathPattern:path keyPath:rootKeyPath statusCodes:[NSIndexSet indexSetWithIndex:200]];[manager addResponseDescriptor:responseDescriptor];[manager postObject:nil path:path parameters:queryParams success:^(RKObjectRequestoperation *operation,RKMapPingResult *mapPingResult) {if (mapPingResult.array.count != 0) { NSDictionary *data = mapPingResult.array[0]; NSLog(@"data: %@",data); }else{ NSLog(@"Unable to fetch data from: %@",path);}} failure:^(RKObjectRequestoperation *operation,NSError *error) { NSLog(@"Error response': %@",error);}]; 除了nspredict和过滤数据之外,是否可以在映射时手动插入值(如字符串)?
解决方法 您可以在完成块中修改映射结果中的对象,但是您需要显式保存上下文,并且上下文的其他观察者将收到保存通知.这是超级简单的方法.或者,您可以覆盖willSave或使用NSManagedobjectContextwillSaveNotification(后者是更好的选项)来触发您的自定义逻辑.然后,您的更改将与RestKit更改一起内联,并将自动保存.
总结以上是内存溢出为你收集整理的ios – Restkit在映射时添加自定义值全部内容,希望文章能够帮你解决ios – Restkit在映射时添加自定义值所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)