views:

98

answers:

1

Hi guys.

I am using NSURLConnection on the application. To create HTTP connection, I used following code :

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL 
                                       URLWithString:@"http://www.mydomain.com/path/[email protected]"]                       cachePolicy:NSURLRequestUseProtocolCachePolicy 
                                     timeoutInterval:45];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:request 
                                                                 delegate:self];

But it throws some exception for this request on the console:

Connection failed! Error - bad URL (null)

So, I've put the URL on address field of Safari. Safari fixed URL to :

http://www.mydomain.com/path/sample.php?id=%1B%[email protected]

How to correct the URL like Safari ?

Is there an API methods related this issue ?

Thanks in advance.

+1  A: 

Use the -stringByAddingPercentEscapesUsingEncoding: method on NSString before passing it to NSURL. You should be able to pass NSASCIIStringEncoding for what you're doing.

Ben Gottlieb
Cool. Thanks a lot. Working fine