我之前一直在从我的Parse后端检索图像,使用以下代码行在UIImageView中显示:
let userPicture = PFUser.currentUser()["picture"] as PFFile
userPicture.getDataInBackgroundWithBlock { (imageData:NSData, error:NSError) -> Void in
if (error == nil) {
self.dpImage.image = UIImage(data:imageData)
}
}
但是我遇到了这个错误:
'AnyObject?' 不能转换为 'PFFile'; 你是否想使用 'as!' 进行强制转换?
苹果公司提供了“有用”的修复提示,建议使用 "as!" 进行更改,但是之后我又收到了这个错误:
“AnyObject?”无法转换为“PFFile”
在 'getDataInBackgroundWithBlock' 部分,我还遇到了这个错误:
不能使用类型为 '((NSData,NSError) -> Void)' 的参数列表调用 'getDataInBackgroundWithBlock'
请问有人能够解释如何在 Swift 1.2 中正确地从 Parse 检索照片并将其显示在 UIImageView 中吗?