gpt4 book ai didi

ios - swift : How to get Inverse relationship in Parse. com

转载 作者:可可西里 更新时间:2023-11-01 02:27:33 26 4
gpt4 key购买 nike

我在 Parse 中有一类名为“用户”的用户。

我像这样设置用户与其他用户的 PFRelation:

  let relation : PFRelation = currentUser.relationForKey("KfriendsRelation")

假设我有用户 1,我可以检索此特定用户关注的所有用户:

    if let friendsRelation: AnyObject! = userPassed.objectForKey("KfriendsRelation")  {

println(friendsRelation)

if friendsRelation != nil {

let findUser : PFQuery = friendsRelation.query()
findUser.whereKey("objectId", notEqualTo: PFUser.currentUser().objectId)


findUser.findObjectsInBackgroundWithBlock....

如果我想检索所有关注用户 1 的用户,我应该怎么做?

我做了这个,但它不起作用:

      let findUser : PFQuery =  PFUser.query()
findUser.whereKey("kfriendsRelation", equalTo: user 1)



findUser.findObjectsInBackgroundWithBlock { (objects:[AnyObject]!, error:NSError!) -> Void in
if !(error != nil) {
// The find succeeded.
println("succesfull load Users in FollowingTableView")
println(objects.count)
// Do something with the found objects
for object in objects {
self.followingUserList.addObject(object)
println(object)
}
self.tableView.reloadData()
} else {
// Log details of the failure
println("error loadind user ")
println("error")
}

} }

它向我打印“在 FollowingTableView 中成功加载用户”,但 println(object.count) 向我打印“0”。我确定有物体,所以我很困惑......

最佳答案

内置的 User 类没有“User”作为它的类名。如果您正在查询内置的 User 类,您应该使用 PFUser's query method 返回的 PFQuery 对象而不是查询“用户”类。

关于ios - swift : How to get Inverse relationship in Parse. com,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26522764/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com