如何访问PFObject内的信息?

时间:2016-04-29 04:33:29

标签: ios swift parse-platform pfobject

我从parse导入对象,但我需要访问其中的信息。该对象具有用户的名称和地址,我需要获取这些。我该怎么做?

let query = PFQuery(className: "People")
    query.findObjectsInBackgroundWithBlock { (objects: [PFObject]?, error: NSError?) in
        if(error == nil){
            for object in objects!{

                self.peopleObj.append(object)



            }


        }else{
            print(error)
        }
}

我会做peopleObj["Name"]这样的事情,我不认为这是PFObject的正确语法。

1 个答案:

答案 0 :(得分:1)

只需循环访问单个对象,然后获取如下所示的值:

for Oneobject in objects
{
   let strAddress = Oneobject["address"] as String
   let strName = Oneobject["name"] as String
}

请参阅以下链接: https://parse.com/docs/ios/guide#objects-retrieving-objects