url 为:(null) 但请求字符串不为 null

发布于 2024-12-01 00:00:32 字数 584 浏览 2 评论 0原文

当我使用此代码时:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

硪扪都還晓 2024-12-08 00:00:32

因为您的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文