NSURLErrorDomain,代码=

编程入门 行业动态 更新时间:2024-10-18 19:28:09
本文介绍了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,代码=

本文发布于:2023-11-26 18:14:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634646.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:代码   NSURLErrorDomain

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!