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¶m2=value2 (percent-encoded)
Obviously I can construct the query part of the URL manually but it seems like there is probably a better way.
Thanks!
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;
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.