views:

20

answers:

1

Hi,

I'm using HTTP connection to share data with my JSON server.

I use URLs like "MyServlet?param1=value1" and so on...

I'm now facing a problem with one of my servlet (I can't change it because some other views are using it) :

The servlet is working with a syntax including those symbols "{" and "}".

The exact syntax is

{(value1_value2)(value3_value4)(value5_value6)}{(value7_value8)(value9_value10)(value11_value12)}{(value13_value14)(value15_value16)(value17_value18)}

Values are integers, the problem is only when I use "{" and "}" my UrlConnection returns an error for bad URL.

I use this to instantiate my NSString :

NSString *myURL = [NSString stringWithFormat:@"http://somesite.com/Servlet?PARAM={(%@)}"];

How can I code those char in my NSString ?

Thanks in advance !

+2  A: 

You need to URL encode those characters. Replace { with %%7b and } with %%7d in your string format. (The extra % is needed because % is special in format strings)

walkytalky
Works like a charm !Thanks for the Wikipedia link too, very helpful !
Dough