我做了噩梦。
我有一个名为Transactions
的Parse类,它有3个指向每个类的指针:
这是班级User
现在我要做的是CustomTableView
显示所有Transactions
,我想将Username
放在单元格内。像这样:
问题是我无法找到正确的查询来使用这些指针获取此信息。什么都行不通......什么查询给我该交易的用户名?谢谢
答案 0 :(得分:1)
如果您正在寻找所有交易:
var query = PFQuery(className:"Transaction")
query.includeKey("PointerUser")
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]?, error: NSError?) -> Void in
if error == nil {
// The find succeeded.
println("Successfully retrieved \(objects!.count) scores.")
// Do something with the found objects
if let objects = objects as? [PFObject] {
for object in objects {
//because we used the include key command
//we can now access the user associated with PointerUser
println(object["PointerUser"]["Username"])
}
}
} else {
// Log details of the failure
println("Error: \(error!) \(error!.userInfo!)")
}
}