swift - 从 Parse.com 检索 PFFile 时为 "unexpectedly found nil while unwrapping an Optional value"

标签 swift parse-platform ios8 xcode6

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

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

最佳答案

尝试:

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

}

关于swift - 从 Parse.com 检索 PFFile 时为 "unexpectedly found nil while unwrapping an Optional value",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25948401/

相关文章:

ios - Swift - 谓词通过成员数组的属性过滤数组

ios - 在 Swift 中为 Parse 的 PFRelation 声明一个只读的@NSManaged 属性

android - 初始化 Parse 时无法解析符号配置

ios - 使用 iOS6 SDK 提交应用更新

ios - 在所需的初始化中从 NSCoder 获取属性(编码器 aDecoder : NSCoder)

ios - GMSMarker 不显示 GroundAnchor iOS

json - 从 Parse 导出密码

ios - 带有 App Group 的 NSUserDefault 在 iOS 8 Beta3 中不起作用

swift - 缺少子模块 'homeKit' 在 Mavericks 上的 XCode6 上构建示例应用程序时出错

ios - 如何在 UIView 中使 SwiftUI View 透明或半透明?