【发布时间】:2017-11-06 04:50:19
【问题描述】:
我有回复我想从image_path下载图片
let fileUrl = NSURL(fileURLWithPath: (posts.value(forKey: "image_path") as! [String])[indexPath.row])
print(fileUrl as Any) // here i can get path
if FileManager.default.fileExists(atPath: (fileUrl)// nil value {
let url = NSURL(string: (posts.value(forKey: "image_path") as! [String])[indexPath.row]) // Here url found nil
let data = NSData(contentsOf: url! as URL)
cell.LocationImage?.image = UIImage(data: data! as Data)
}
更新:
【问题讨论】:
-
用 afnetworking 3.0 stackoverflow.com/questions/36007238/… 查看我的答案,或者您可以使用 sd webimage 下载图像。如果您的网址在服务器外部
-
@ViralRathod 您的 image_path 是帖子响应中的 URL??
-
@TusharSharma 帖子是我对肥皂的回应,'posts.value(forKey: "image_path") as! [字符串])[indexPath.row]'
-
@ViralRathod 我的意思是键“image_path”的值是什么。它是 URL 吗??
标签: ios iphone swift swift3 uiimageview