本文介绍了NSURLRequest中不支持的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我从终端运行此请求,我可以正常看到JSON请求:
If I run this request from my terminal I can see the JSON requests as normally:
curl -XGET 192.168.0.6:8888/scripts/data/backend2/index.php/name/_all
我的NSURlRequest代码是这样:
My code for the NSURlRequest is this:
NSURLRequest *request = [NSURLRequest requestWithURL:
[NSURL URLWithString:@"192.168.0.6:8888/scripts/data/backend2/index.php/name/_all"]];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
我收到此错误:
didFailWithError
2013-11-29 22:31:08.164 Ski Greece[607:a0b] Connection failed: Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo=0xcd042d0 {NSErrorFailingURLStringKey=192.168.0.6:8888/scripts/data/backend2/index.php/name/_all, NSErrorFailingURLKey=192.168.0.6:8888/scripts/data/backend2/index.php/name/_all, NSLocalizedDescription=unsupported URL, NSUnderlyingError=0xdbdcc70 "unsupported URL"}
如何调用该URL?我无法访问服务器代码 - 我知道如果我调用该URL,它只是设置回报我需要的东西吗?
How can I make the call to that URL? I cannot access the server code - I know it is just setup to return me what I need, if I call that URL?
推荐答案
尝试在您的网址中加入适当的网址方案,例如
Try to include appropriate url scheme to your url, e.g.
[NSURL URLWithString:@http:// www ...
这篇关于NSURLRequest中不支持的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!