Friday, 13 September 2013

obj-c dictionary to url parameter string

obj-c dictionary to url parameter string

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.

No comments:

Post a Comment