0

I have a PFUser with a Skills column.

Typically I can use user.skills (or user["skills"]) to get the skills objects of the user.

But to use these with PFQueryTableViewController I need to construct some sort of PFQuery when overriding queryForTable to get the list of skills for a user.

How do I build this query? All it does is return the skills for a given user.

1 Answer 1

0
fetchSkills(){
     var userQuery: PFQuery = PFUser.query()!

     userQuery.wherekey("username", equalTo: (currentUser?.username)!)

     userQuery.findObjectsInBackgroundWithBlock({
        (users, error) -> Void in

        var skills = users!


        if error == nil {
            if skills.count >= 1 {
                for i in 0...users!.count-1 {
                    self.skillTypes.append(skills[i].valueForKey("UserSkills") as! String)

                }
            }
            self.usersArray = users as! [PFUser]
            self.tableView.reloadData()
        } else {
            print(error)
        }
    })
}
1
  • The query results go straight to override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?), thus I will have use objects instead of the skills. I guess its a limitation of the PFQueryTableVC and something custom will be required.
    – realtimez
    Jan 27, 2016 at 12:39

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.