2

I am trying to get an array of PFObjects, [PFObject], from Parse and seeing the issue below. What am I missing?

Error is Missing argument for parameter #1 in call

func loadData() {
    rooms = [PFObject]()
    users = [PFUser] ()

    self.tableView.reloadData()

    let pred = NSPredicate(format: "user1 = %@ OR user2 = %@", PFUser.currentUser()!, PFUser.currentUser()!)

    let roomQuery = PFQuery(className: "Rooms", predicate: pred)

    //gives us all the information - includeKey all columns for the user class itself
    roomQuery.includeKey("user1")
    roomQuery.includeKey("user2")

    roomQuery.findObjectsInBackgroundWithTarget{ (results: [AnyObject]!, error: NSError!) -> Void in

        if error == nil {
            self.rooms = results as [PFObject]

            for room in self.rooms {
                let user1 = room.objectForKey("user1") as PFUser
                let user2 = room.objectForKey("user2") as PFUser

                if user1.objectId != PFUser.currentUser() {
                    self.users.append(user1)
                }

                if user2.objectId != PFUser.currentUser() {
                    self.users.append(user2)
                }
            }
         self.tableView.reloadData()

        }


    }

}

Error: enter image description here

user1406716
  • 9,565
  • 22
  • 96
  • 151

1 Answers1

3

It seems that you want to handle the response with a block but you decided to use findObjectsInBackgroundWithTarget. You should go with findObjectsInBackgroundWithBlock:. So you should be having something like this:

roomQuery.findObjectsInBackgroundWithBlock {(objects: [AnyObject]?, error: NSError?) -> Void in
Vasil Garov
  • 4,851
  • 1
  • 26
  • 37