'Unable to execute comparison request for type: PFRelation' Swift

I am trying to query all existing users in my application that the user has not added as "Friend." I get an error

Unable to complete comparison request for type: PFRelation

Here is my current code:

override func queryForTable() -> PFQuery { let currentFriends : PFRelation = PFUser.currentUser()!.relationForKey("friends") // Start the query object let query = PFQuery(className: "_User") query.whereKey("username", notEqualTo: currentFriends) // Add a where clause if there is a search criteria if UserInput.text != "" { query.whereKey("username", containsString: UserInput.text) } // Order the results query.orderByAscending("username") // Return the qwuery object return query } 

How to solve this problem? Thanks

+7
swift pfrelation
source share
1 answer

I solved my problem ... in a way. I was not able to compare PFRelation, so I created a helper class, Parse, which saves the user who adds the other user as "from" and the user they add as "in", then I can compare them.

 let currentUser = PFUser.currentUser()?.username let currentFriends = PFQuery(className: "Friends") currentFriends.whereKey("from", equalTo: currentUser!) // Start the query object let query = PFQuery(className: "_User") query.whereKey("username", doesNotMatchKey: "to", inQuery: currentFriends) 

I hope this helps someone in the future.

+5
source share

All Articles