NSURL doesn't seem to want to accept my requests

Hi i have this code

NSLog(@"%@",URLRequestQueryString); NSString *sendToServerString = [NSString stringWithFormat:@"http://mydomain.co.uk/req.php%@",URLRequestQueryString]; NSURL *sendToServer = [[NSURL alloc] initWithString:sendToServerString]; NSLog(@"%@",sendToServer); NSLog(@"%@",sendToServerString); 

URLRequestQueryString is the standard query string that I created in all of the script.

The first NSLog works fine and displays the correct sequence (if I copy and paste it into the browser, then the page will load and launch correctly.

This is also the case when I output sendToServerString , it correctly displays the URL using the query string (which I can also copy and paste into the browser).

However, sendToServer outputs (null). If I delete the request, it will correctly display the domain and path.

Any idea why this is happening? How can I sort it?

Thanks.

+4
source share
2 answers

NSURL *sendToServer = [NSURL URLWithString: [sendToServerString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]];
Maybe what you are looking for. :)

+7
source

You need to see the NSString link. Section "Working with URLs". There are two methods in this section.

+3
source

All Articles