我打算检索当前用户的分数。这是我的代码。提前致谢。
let query = PFQuery(className: "UserData")
query.whereKey("user", equalTo: "cuWkby3Fm0")
query.findObjectsInBackgroundWithBlock {
(objects: [PFObject]?, error: NSError?) -> Void in
if error == nil {
print("successfully retrieved \(objects!.score) ")
} else {
print("Error: \(error!) \(error!.userInfo)")
}
错误是
Value of type '[PFObject]' has no member 'score'
最佳答案
objects
是类型 [PFObject]?
- PFObject
的可选数组。
您可能想要获得一些 所包含元素的分数。例如:
if let first = objects.first {
print(first["score"])
}
关于swift - 使用 query.whereKey 在 Swift 中解析查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34664601/