Reputation: 1193
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.
Upvotes: 1
Views: 576
Reputation: 85522
Use the -stringByAddingPercentEscapesUsingEncoding: method on NSString before passing it to NSURL. You should be able to pass NSASCIIStringEncoding for what you're doing.
Upvotes: 3