b3rge b3rge - 6 months ago 34
Swift Question

How can I access value from pointer inside pointer on query with Parse in swift?

How can I access value from pointer inside pointer on query with Parse in swift?

This has to do with three classes in Parse. One is called Post_Story, on is Post and one is User. When I query for Post_Story i am able to retreive pointer info from a key "Post", but is there any way to access information from a pointer within that pointer? (key "createdBy" to User class)

My code looks like this:

let postQuery = PFQuery(className: "Post_Story")
postQuery.whereKey("story", containedIn: storyObjects)
postQuery.includeKey("post")

postQuery.findObjectsInBackgroundWithBlock { (objects:[PFObject]?, error:NSError?) in
if error == nil {
for object in objects! {
if let postL = object["post"] as? PFObject {

if postL["createdBy"] != nil {

//this is where I want to get infor from PFUser, but not all info is sent
print((postL["createdBy"] as! PFUser)) //prints PFUser object without username etc.

}
}
}
}
else {}
}


I hope the question is not too stupid...

Answer

You can add postQuery.includeKey("post.createdBy") to include the user object in the createdBy column of post.

Comments