0

Are there any built in methods (or really simple examples, not using libraries) that can turn a dictionary into a url parameter string (to be appended to url). I'm expecting something similar to the psuedo below:

objectSerialization(obj){
  var ret = "";
  for(key in obj){

    if(dict[key] is "array"){
      ret = objectSerialization(dict[key]);
    }else{
      ret += key + "=" + dict[key];
    }
    ret += "&";
  }
  return ret;
}

Obviously there may be glaring bugs in this example, but the idea is there. I suppose I could just port this example into obj-c code, but my question is if there is a more acceptable way of doing this. The main purpose of this is to build GET request urls with dynamic url parameters, originally contained in dictionaries. Thanks for any help.

anson
  • 4,156
  • 2
  • 22
  • 30
  • Check out Apple's NSString documentation, especially working with URLs section – aug2uag Sep 14 '13 at 06:07
  • [this question has already been asked](http://stackoverflow.com/questions/718429/creating-url-query-parameters-from-nsdictionary-objects-in-objectivec) [and answered here before](http://stackoverflow.com/questions/7060692/asihttprequest-how-to-convert-nsdictionary-of-params-to-url-encoded-query-para) [at least a couple times](http://stackoverflow.com/questions/1250212/encoding-string-arguments-for-urls) – Michael Dautermann Sep 14 '13 at 06:33

0 Answers0