iosswiftparse-platformpfobject

How do I gain access to the info inside a PFObject?


I am importing the objects from parse, but I need to gain access to the information inside. The object has the name and the address of a user, and I need to get those. How would I do that?

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)
        }
}

Would I do something like peopleObj["Name"], I don't think that is the correct syntax for a PFObject.


Solution

  • Just make a loop to access the single object and then fetch value like below:

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

    Refer the following link: https://parse.com/docs/ios/guide#objects-retrieving-objects