ios - 发布路径必须与 RKResponseDescriptor pathPattern 完全匹配

标签 ios json url restkit

因此,我当前用于更新对象的服务遵循以下 URL 的格式

http://www.baseurl.com/servicemethodAddObject/transactionId?clientTime=clientTime

所以这是我放在那里的代码。大概。

[objectManager addResponseDescriptor:[RKResponseDescriptor responseDescriptorWithMapping:eventResponseMapping method:RKRequestMethodGET pathPattern:@"/GetStuff" keyPath:nil statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]];

// I'd want to add items to the URL but the parameters parameter only goes in to the post body, If I add objects to the path @"?GetStuff/?parm=Stuff&parm2=stuff2" then the response will not be mapped properly
[objectManager postObject:object path:@"/GetStuff" parameters:parms success:nil failure:nil];

看来RestKit要求用于发布对象的路径和用于创建RKDescriptor的pathPattern必须完全匹配。有没有办法让restKit进行比较,忽略其对象映射的url参数?

这是正确的做法吗?发布对象并在 URL 中添加项目。

最佳答案

您可以构建路径来添加参数。使用 pathPattern:@"/GetStuff" 将匹配构建的路径,例如:

@"/GetStuff?parm=Stuff&parm2=stuff2"

(如果添加或删除不在路径模式中的 / 字符,您将遇到问题)

关于ios - 发布路径必须与 RKResponseDescriptor pathPattern 完全匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23203532/

相关文章:

ios - 过滤嵌套数组和字典

ios - 需要有关在 UINavigationcontroller 中将数据从 child 传递给 parent 的帮助

java - JAVA中如何解析父子相关的JsonArray?

javascript - 服务器端使用 Django 访问客户端浏览器的纬度/经度

javascript - 如何匹配但排除正则表达式模式?

javascript - 当我通过 AJAX 管理我的网站时如何更新我的 URL?

ios - Apns 证书未安装在我的 mac 书中

ios - xcode 5 水平 ScrollView 不工作 (iOS7)

php - JSON NSDictionary 在输出到日志时显示空描述

安卓 : Load image from web URL