Iphone NSURL不';我似乎不想接受我的质询
你好,我有这个密码Iphone NSURL不';我似乎不想接受我的质询,iphone,query-string,nsurl,Iphone,Query String,Nsurl,你好,我有这个密码 NSLog(@"%@",URLRequestQueryString); NSString *sendToServerString = [NSString stringWithFormat:@"http://mydomain.co.uk/req.php%@",URLRequestQueryString]; NSURL *sendToServer = [[NSURL alloc] initWithString:sendToServerString]; NSLog(@"%@",se
NSLog(@"%@",URLRequestQueryString);
NSString *sendToServerString = [NSString stringWithFormat:@"http://mydomain.co.uk/req.php%@",URLRequestQueryString];
NSURL *sendToServer = [[NSURL alloc] initWithString:sendToServerString];
NSLog(@"%@",sendToServer);
NSLog(@"%@",sendToServerString);
URLRequestQueryString只是我在整个脚本中构建的一个标准querystring
第一个NSLog工作正常,并输出正确的查询字符串(如果我将其复制并粘贴到浏览器中,则页面将正确加载并运行)
当我输出sendToServerString
时,它也会正确输出带有querystring的URL(我也可以将其复制并粘贴到浏览器中)
但是sendToServer
outputs(null)。如果删除查询字符串,它将正确输出域和路径
知道为什么会这样吗?我怎么分类
谢谢。
NSURL*sendToServer=[NSURL URLWithString:[sendToServerString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
可能就是您要查找的内容。:)您需要查看NSString参考。 一个名为“使用URL”的部分。 本节下有两种方法
- StringByReplacing百分比转义使用编码: