有什么方法可以在 RestKit 0.20 中指定带有参数的路径模式? [英] Any way to specify a path pattern with parameters in RestKit 0.20?

查看:41
本文介绍了有什么方法可以在 RestKit 0.20 中指定带有参数的路径模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用路径 object?special=true&id=100 应该映射到 SpecialObject 和路径 object?special=false&id=100 应该映射到 RegularObject.

I am trying to consume a web service for which the path object?special=true&id=100 should map to a SpecialObject and path object?special=false&id=100 should map to a RegularObject.

但是当我尝试使用 "object?special=true""object?special=false"pathPatterns 在我的RKResponseDescriptors 它不起作用 - RestKit 报告 URL object?special=true&id=100 不匹配任何描述符.

But when I try to use pathPatterns of "object?special=true" and "object?special=false" in my RKResponseDescriptors it is not working - RestKit reports that the URL object?special=true&id=100 does not match any descriptors.

是否可以指定包含特定参数值的 RKResponseDescriptor 中使用的路径模式?

Is it possible to specify a path pattern for use in RKResponseDescriptor that incorporates a specific parameter value?

推荐答案

并非如此.模式匹配基于路径,而不是参数.我认为在模式匹配期间不可能使用这些参数.

Not really. The pattern matching is based on the path, not the parameters. I don't think it's possible to use the parameters during pattern matching.

一种选择是使用动态映射,该映射查看 URL 并解释查询参数以决定映射.

One option is to use a dynamic mapping which looks at the URL and interprets the query parameters to decide the mapping.

另一种选择是在映射时使用元数据,因为这使您可以访问 URL 及其包含的参数.

Another option could be to use metadata while mapping as this gives you access to the URL and the parameters it contains.

这篇关于有什么方法可以在 RestKit 0.20 中指定带有参数的路径模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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