ios - 获取空的用户名字符串

标签 ios swift parse-platform

var query = PFQuery(className:"FriendRequest")
        query.whereKey("receiver", equalTo: PFUser.currentUser())
        query.findObjectsInBackgroundWithBlock {
            (objects: [AnyObject]?, error: NSError?) -> Void in
            if let objects = objects as? [PFObject] {
                self.friendRequestArray = objects
                let user = self.friendRequestArray[0]["sender"] as PFUser
                println(user.username) //prints blank string.
                self.tableView.reloadData()
            }
        }

您好,为什么我的 println(user.username) 在这种情况下没有打印任何内容?数组中有许多对象,["sender"] 指向一个有效的用户。

这是怎么回事?

编辑:self.friendRequestArray 早先初始化为 [PFObject]() edit2:也没有发生错误,因为错误对象为零。

最佳答案

在调用 findObjectsInBackgroundWithBlock 之前添加 query.includeKey("sender")

关于ios - 获取空的用户名字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30132752/

相关文章:

ios - UIImagePickerController - 在相机上完成关闭(Swift)

ios - 使用 Swift 解析中的 SDWebImage 实现

ios - 快速更新 addQuadCurve 控制点?

iOS 框架在初始归档后无法更新

iphone - 从 Phonegap 过渡到原生应用

c++ - Swift - 使用 Objective-C 包装器调用 C++ 文件 - 传递 Int 值

ios - Swift - 应用程序内的深层链接以启动弹出 View Controller

parse-platform - 限制用户更新某些字段但允许后端编辑它们

javascript - 在 promise 中更直接地使用函数

ios - 刷新数据后 IBOutlet nil