【问题标题】:"unexpectedly found nil while unwrapping an Optional value" when retriveing PFFile from Parse.com从 Parse.com 检索 PFFile 时,“在展开可选值时意外发现 nil”
【发布时间】:2014-09-20 11:44:50
【问题描述】:

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

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”列存在,但可以为空。

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

【问题讨论】:

    标签: swift parse-platform ios8 xcode6


    【解决方案1】:

    试试:

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

    【讨论】:

    • 是的!谢谢你。解决:如果让 userImageFile = user[ParseUserClassTablesName.PROFILEIMAGE.description()] 为? PFFile{ userImageFile.getDataInBackgroundWithBlock { (imageData: NSData!, error: NSError!) -> Void in if error == nil { if imageData != nil{ let image = UIImage(data:imageData) self.profileImage.image = image } } } }
    • 这是如何为您解决问题的?我遇到了同样的问题,这并不能解决问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-01-23
    • 2016-10-18
    • 2017-04-09
    • 2018-09-22
    • 2016-06-26
    • 2016-03-12
    相关资源
    最近更新 更多