ios - 带有自定义 URL 的 RKResponseDescriptor

标签 ios objective-c rest restkit

在这种情况下最好的方法是什么?

我有通往里程碑资源的路径:

GET: {baseURL}/rest/v2/common/plans/{id}/milestones

还有这条通往不同资源的路径:

GET: {baseURL}/rest/v2/common/plans/{id}/statistics

为了正确解析它,我需要在发出任何请求之前定义描述符:

RKResponseDescriptor *responseDescriptor = 
    [RKResponseDescriptor responseDescriptorWithMapping:...

具有正确定义的路径。我认为 responseDescriptor 始终是一个静态实例,不需要在应用程序生命周期内重新创建(在此之前我使用请求的主体)。

但在 {id} 以上路径的情况下,将路径性质更改为动态路径。每当我发送具有不同 {id} 的请求时,我是否应该始终重新定义 responseDescriptor?使用 {baseURL}/rest/v2/common/plans/定义路径是不明确的。

使用 RK 版本 0.26.0。

最佳答案

不,这是路径模式是有原因的:

@"/rest/v2/common/plans/:id/milestones"

另请注意,使用 /rest/v2/common/plans/ 是不完整的路径,不会匹配。

关于ios - 带有自定义 URL 的 RKResponseDescriptor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37730730/

相关文章:

ios - CTFramesetterCreateFrame 返回 nil

ios - 为什么我不能使用 segue 传递数据

java - 连接 Java Rest 服务

objective-c - 无需运行循环的 MacOSX 套接字编程

rest - 使用 SharePoint 2013 REST API 添加列表项

java - Spring PUT 请求 : Unsupported Media Type (Code: 415)

ios - 在drawAtPoint期间崩溃,代码在iPad Air、iPad模拟器上运行,在iPad 1和iPad mini上崩溃

iphone - iOS 应用程序中的气泡图

iOS 客户端,C++ 服务器?

ios - 如何访问 objective-c 文件中的 swift 类