url 为:(null) 但请求字符串不为 null
当我使用此代码时:
NSString *requestText;
requestText = [NSString stringWithFormat:
@"http://makrr.com/Music/*******/*****/******.php?search=%@",
searchField.text];
NSLog(@"requestText is: %@", requestText);
NSURL *url;
url = [NSURL URLWithString:requestText];
NSLog(@"url is: %@", url);
日志显示:
2011-08-19 10:12:10.172 Rumblrr[2246:607] requestText is: http://makrr.com/Music/*******/*****/******.php?search=******
2011-08-19 10:12:10.175 Rumblrr[2246:607] url is: (null)`
When I use this code:
NSString *requestText;
requestText = [NSString stringWithFormat:
@"http://makrr.com/Music/*******/*****/******.php?search=%@",
searchField.text];
NSLog(@"requestText is: %@", requestText);
NSURL *url;
url = [NSURL URLWithString:requestText];
NSLog(@"url is: %@", url);
The log shows:
2011-08-19 10:12:10.172 Rumblrr[2246:607] requestText is: http://makrr.com/Music/*******/*****/******.php?search=******
2011-08-19 10:12:10.175 Rumblrr[2246:607] url is: (null)`
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为您的 requestText 中有些内容无法转换为 URL。
检查您的 requestText 中的 ** 部分,看看是否有一些文本需要先进行 URL 编码。
Because there are some thing in your requestText can NOT be convert to an URL.
Check your requestText about the ** parts, see if there are some text need to be URL Encoded first.