“在解开一个 Optional 值时意外发现 nil"从 Parse.com 检索 PFFile 时 [英] "unexpectedly found nil while unwrapping an Optional value" when retriveing PFFile from Parse.com

查看:21
本文介绍了“在解开一个 Optional 值时意外发现 nil"从 Parse.com 检索 PFFile 时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在检索 Parse.com 中存储的 PFFile 时遇到问题

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
                    }
                }
            }

错误从第二行开始.列profileImage"存在,但可以为空.

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

有人可以帮助我吗?谢谢.

Someone can help me? Thank you.

推荐答案

尝试:

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

}

这篇关于“在解开一个 Optional 值时意外发现 nil"从 Parse.com 检索 PFFile 时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆