Tri*_*ips 7 parse-platform pfrelation swift
我正在尝试查询我的应用中用户尚未添加为"朋友"的所有现有用户.我收到了错误
无法对类型进行比较查询:PFRelation
这是我目前的代码:
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
}
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?谢谢
我在某种程度上解决了我的问题.我无法比较PFRelation所以我创建了一个帮助Parse类,它保存将其他用户添加为"from"的用户和他们添加为"to"的用户然后我能够像这样比较它们.
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)
Run Code Online (Sandbox Code Playgroud)
我希望这可以帮助将来的某个人.
| 归档时间: |
|
| 查看次数: |
223 次 |
| 最近记录: |