NSURLRequest中不支持的URL

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (90)

如果我从终端运行此请求,我通常可以看到JSON请求:

curl -XGET 192.168.0.6:8888/scripts/data/backend2/index.php/name/_all

我的NSURlRequest的代码是这样的:

 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"}

我怎样才能调用该网址?

提问于
用户回答回答于
用户回答回答于
strURL = [strURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

扫码关注云+社区

领取腾讯云代金券