NSURLErrorDomain,代码= -1100 [英] NSURLErrorDomain with code=-1100
本文介绍了NSURLErrorDomain,代码= -1100的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图从我的应用程序下载图片
I was trying to download a picture to my app from
请求失败,错误为NSURLErrorDomain,代码实际为-1100。网址应该是正确的,因为我在浏览器中检查了它。谁知道为什么?
The request failed with the error NSURLErrorDomain and the code is really -1100. The url should be correct since I checked it in the browser. Anyone knows why?
let userImageURL: String! = "http://i.imgur.com/QhCzQoR.jpg";
let url = NSURL(fileURLWithPath: userImageURL);
let request:NSURLRequest = NSURLRequest(URL: url!)
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue(), completionHandler: { (response:NSURLResponse!, imageData:NSData!, error:NSError!) -> Void in
let image = UIImage(data: imageData!);
})
推荐答案
您遇到此问题的原因是因为您已经使用了
The reason you are getting this problem is because you have used
let url = NSURL(fileURLWithPath: userImageURL);
相反,你应该使用:
let url = NSURL(string: userImageUrl)
这篇关于NSURLErrorDomain,代码= -1100的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文