使用NSURL发送http出错的解决方法

about出错原因

在加载某张图的时候,采用了如下代码

let url = NSURL(string: "http://ww2.sinaimg.cn/large/6a8020f7gw1ey7895z2yuj20c808qwf5.jpg")
    sd_setImageWithURL(url, placeholderImage: nil, options: .CacheMemoryOnly, progress: {
      [weak self]
      (receivedSize, expectedSize) -> Void in
      // Update progress here
      }) {
        [weak self]
        (image, error, _, _) -> Void in
        // Reveal image here
    }

结果,Xcode报错:
Application Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app‘s Info.plist file.

最后的解决方法:

在Info.plist文件中增加App Transport Security Settings:


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容