1
votes

I get this error message on this line of this code:

findSweeter.whereKey("objectId", equalTo: sweet.objectForKey("sweeter")!.objectId)

Error:

cannot invoke 'whereKey' with an argument its of type '(String, equalTo: String?!)'

Here is the code that I have used in the cellForRowAtiIndex path to retrieve the profile image, profilename, and content to display in the cell:

var findSweeter:PFQuery = PFUser.query()!
  findSweeter.whereKey("objectId", equalTo: sweet.objectForKey("sweeter")!.objectId)

  findSweeter.findObjectsInBackgroundWithBlock{
      (objects:[AnyObject]?, error:NSError?)->Void in

      if error == nil{
          let user:PFUser = (objects as! NSArray).lastObject as! PFUser
          cell.usernameLabel.text = user.username


          UIView.animateWithDuration(0.5, animations: {
              cell.sweetTextView.alpha = 1
              cell.timestampLabel.alpha = 1
              cell.usernameLabel.alpha = 1
              cell.profilePic.alpha  = 1
          })
      }
  }

Any solution to this problem would be greatly appreciated. Using Xcode 6.3.2. Thank you in advance!

1

1 Answers

0
votes

Try unwrapping the optional variable before the query.

if let sweeter: PFObject = sweet.objectForKey("sweeter") as? PFObject {
    var findSweeter:PFQuery = PFUser.query()!
    findSweeter.whereKey("objectId", equalTo: sweeter.objectId)
    findSweeter.findObjectsInBackgroundWithBlock {
        // ...
    }
}