从指针访问另一个类列 - Parse

时间:2015-08-26 23:39:21

标签: ios swift parse-platform tableview

我做了噩梦。

我有一个名为Transactions的Parse类,它有3个指向每个类的指针:

enter image description here

这是班级User

enter image description here

现在我要做的是CustomTableView显示所有Transactions,我想将Username放在单元格内。像这样:

enter image description here

问题是我无法找到正确的查询来使用这些指针获取此信息。什么都行不通......什么查询给我该交易的用户名?谢谢

1 个答案:

答案 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!)")
    }
}