ASIHttpRequest-如何将参数的NSDictionary转换为url编码的查询参数字符串? [英] ASIHttpRequest - how to convert NSDictionary of params to url-encoded query param string?

查看:145
本文介绍了ASIHttpRequest-如何将参数的NSDictionary转换为url编码的查询参数字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用作为NSDictionary提供的查询参数通过ASIHttpRequest进行GET请求的首选方法是什么. 如何得到 来自NSDictionary * params
改为?param1 = value1& param2 = value2(百分比编码)

What is the preferred way to make a GET request with ASIHttpRequest using query params provided as an NSDictionary. How do I get from NSDictionary *params
to ?param1=value1&param2=value2 (percent-encoded)

很明显,我可以手动构造URL的查询部分,但似乎有更好的方法.

Obviously I can construct the query part of the URL manually but it seems like there is probably a better way.

谢谢!

推荐答案

您必须将查询字符串作为URL的一部分传递.从 GitHub 上的ASIHTTPRequest界面中:

You must pass the query string as part of the URL. From the ASIHTTPRequest interface on GitHub:

// The url for this operation, should include GET params in the query string where appropriate
NSURL *url; 

如果您不想使用自己的字典到查询字符串的方法,请查看Mac版Google工具箱中的GTMNSDictionary+URLArguments类别(

If you don't want to roll your own dictionary-to-query-string method, take a look at the GTMNSDictionary+URLArguments category in Google Toolbox for Mac (.h, .m). It adds a method, gtm_httpArgumentString, to NSDictionary that should be what you're after.

这篇关于ASIHttpRequest-如何将参数的NSDictionary转换为url编码的查询参数字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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