0

I have two classes Place and BeenHere. BeenHere has pointers called "toPlace" and "fromUser"with target to Class Place and User accordingly. Place, in its turn, has title and image (PFFile) that I want to retrieve and show in ViewController. In the code below I have reached that pointer with objectId, but don't know how I can now retrieve title and image related to specific place this pointer leads to. Appreciate your help and suggestions.

class UserBeenHereViewController: UIViewController {       
override func viewDidLoad() {
    super.viewDidLoad()

    let user = PFUser.currentUser()?.username

    if user != nil {

    let query = PFQuery(className: "BeenHere")
            query.includeKey("toPlace")
            query.findObjectsInBackgroundWithBlock { (objects, error) -> Void in
        if error == nil {
            for object in objects! {
                print(object["toPlace"].objectId)

            }
        }
            else {
                print("There is error")
            }
        }
    }
}

1 Answer 1

1

First you need to get the "toPlace" into a PFObject and then access it. So in your case it should look something like:

var toPlace = comment["toPlace"] as? PFObject
print (toPlace["title"])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.