Parse.com与所选键的关系查询

时间:2015-09-20 21:22:39

标签: ios swift parse-platform key

我尝试使用一些密钥创建关系查询,但它返回所有密钥。 我做错了什么?

query.getObjectInBackgroundWithId(objectId) { (object:PFObject?, error:NSError?) -> Void in
        if error == nil {

            var relation: PFRelation = object!.relationForKey("MenuDetails")

            relation.query()!.selectKeys(["Receipe_Lvl1"])

            var testArray = NSMutableArray()

            relation.query()!.findObjectsInBackgroundWithBlock {
                (objects: [AnyObject]?, error: NSError?) -> Void in
                if error == nil {
                    if let objects = objects as? [PFObject] {
                        for object in objects {
                            testArray.addObject(object)
                        }
                    }
                } else {

                }

            }

        }


    }

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

我从未使用Parse,但我认为你应该链接方法。

query.getObjectInBackgroundWithId(objectId) { (object:PFObject?, error:NSError?) -> Void in
        if error == nil {

            var relation: PFRelation = object!.relationForKey("MenuDetails")


            var testArray = NSMutableArray()

           relation.query()!.selectKeys(["Receipe_Lvl1"]).findObjectsInBackgroundWithBlock {
                (objects: [AnyObject]?, error: NSError?) -> Void in
                if error == nil {
                    if let objects = objects as? [PFObject] {
                        for object in objects {
                            testArray.addObject(object)
                        }
                    }
                } else {

                }

            }

        }


    }