SDWebImage 总是 returns 错误代码 401

SDWebImage always returns error code 401

我在 Swift 2.0 项目中使用 SDWebImage。当 运行 on iOS 9 它总是 returns 以下错误

Error Domain=NSURLErrorDomain Code=401 "(null)"

使用 SDWebImage 从服务器加载图像

cell.backgroundImageView.sd_setImageWithURL(NSURL(string: "http://..."), placeholderImage: placeholderImg, options: SDWebImageOptions.RetryFailed, completed: {(image, error, type, url) -> Void in
   if error == nil {
      // do something with image          
   }
})

因为它是 iOS 9 上的 http:// 请求和 运行,我也将其添加到我的 Info.plist 文件

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

原来是服务器需要认证才能请求这个图片资源。这就是 SDWebImage 正确返回 401 错误代码的原因。