“unexpectedly found nil while unwrapping an Optional value” when retriveing PFFile from Parse.com

左心房为你撑大大i 提交于 2019-12-31 02:45:09

问题


i've a problem when i retrieve a PFFile stored in Parse.com

let user = PFUser.currentUser()
let userImageFile = user["profileImage"] as PFFile
            userImageFile.getDataInBackgroundWithBlock {
                (imageData: NSData!, error: NSError!) -> Void in
                if error == nil {
                    if imageData != nil{
                        let image = UIImage(data:imageData)
                        self.profileImage.image = image
                    }
                }
            }

The error start at line two. Column "profileImage" exists, but it can be empty.

Someone can help me? Thank you.


回答1:


Try:

if let userImageFile = user["profileImage"] as? PFFile {

}


来源:https://stackoverflow.com/questions/25948401/unexpectedly-found-nil-while-unwrapping-an-optional-value-when-retriveing-pffi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!