0
votes

I am using the NSURL class in the iPhone framework foundation library to create a url request to a server. For some reason, I am getting back a nil for only this particular URL. I don't understand why. Any reason?

The Objective C code is :

NSURL *scriptURL= [NSURL URLWithString:scriptURLString];

where scriptURLString is an NSString with value give below:

http://myserver/cgi-bin/AdsERsubset.cgi?user=139&fieldList=employee_num,mbox_num,last_name,first_name,disp_emp_num,company_num,TECH_PRIVILEDGE,printer_code,desktop_cos,id,supv_emp_num&action=first&searchkey=1 with proxy=DIRECT

The above URL is a CGI request.

Is there a special character I need to escape here?

Please advice. Thanks in advance.

2

2 Answers

0
votes

The spaces in the searchkey should be escaped.

Use stringByAddingPercentEscapesUsingEncoding on the url string before passing it to URLWithString:

NSURL *scriptURL= [NSURL URLWithString:[scriptURLString 
          stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
0
votes

...&searchkey=1 with proxy=DIRECT

Your missing an & aren't you?

I'd imagine it would be more like:

...&searchkey=1&with%20proxy=DIRECT

or

...&searchkey=1&withproxy=DIRECT