本文介绍了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! = "i.imgur/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,代码=
发布评论