iOS - RESTKit 0.20 - 发送多个同名的查询参数 [英] iOS - RESTKit 0.20 - send multiple query parameters with the same name

查看:53
本文介绍了iOS - RESTKit 0.20 - 发送多个同名的查询参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 RESTKit 发送 GET 请求,如下所示:getNames?names=bob&names=joe&names=joey当我尝试使用相同的键名设置参数字典时,它不起作用.仅发送第一个键和值.我知道很久以前有一个关于这个的问题这里.但是仍然没有答案,我想知道这方面是否有任何进展.

I am trying to send a GET request using RESTKit that looks like this: getNames?names=bob&names=joe&names=joey When I try to set the parameters dictionary with the same key names, it don't work. Only the first key and value get sent. I know there's a question about this from a long time ago here. But there is still no answer, and I was wondering if there's any development on this.

推荐答案

我想出了一个解决方案.这是我使用的代码:

I figured out a solution. This is the code I use:

[[RKObjectManager sharedManager] getObjectsAtPath:queryPath
                                           parameters:nil
                                              success:nil failure:nil];

并且 queryPath 看起来像这样:getNames?names=bob&names=joe&names=joey 并且它确实有效.确保使用 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding 以便 &? 将正确通过.

and the queryPath looks like this: getNames?names=bob&names=joe&names=joey and it actually works. make sure to use stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding so that the & and ? will go through properly .

这篇关于iOS - RESTKit 0.20 - 发送多个同名的查询参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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