1
var query = PFQuery(className:"FriendRequest")
        query.whereKey("receiver", equalTo: PFUser.currentUser())
        query.findObjectsInBackgroundWithBlock {
            (objects: [AnyObject]?, error: NSError?) -> Void in
            if let objects = objects as? [PFObject] {
                self.friendRequestArray = objects
                let user = self.friendRequestArray[0]["sender"] as PFUser
                println(user.username) //prints blank string.
                self.tableView.reloadData()
            }
        }

Hello, why is my println(user.username) printing nothing in this scenario? There are numerous objects in the array and ["sender"] points to a valid user.

What is going on?

edit: self.friendRequestArray is initialized earlier as [PFObject]() edit2: No error is occurring either, since the error object is nil.

1 Answer 1

2

Add query.includeKey("sender") before you call findObjectsInBackgroundWithBlock.

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.