Ios Swift:如何在Parse.com中获得反向关系
我在解析中有一个名为“User”的用户类 我设置了一个用户与其他用户的关系,如下所示:Ios Swift:如何在Parse.com中获得反向关系,ios,swift,parse-platform,pfquery,pfrelation,Ios,Swift,Parse Platform,Pfquery,Pfrelation,我在解析中有一个名为“User”的用户类 我设置了一个用户与其他用户的关系,如下所示: let relation : PFRelation = currentUser.relationForKey("KfriendsRelation") 假设我有用户1,我可以检索该特定用户跟随的所有用户: if let friendsRelation: AnyObject! = userPassed.objectForKey("KfriendsRelation") { prin
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")
}
} }
它将我打印为“成功加载以下TableView中的用户”,但println(object.count)将我打印为“0”。
我肯定有对象,所以我很困惑…内置用户类没有“User”作为其类名。如果要查询内置用户类,则应使用通过返回的PFQuery对象,而不是通过“User”类进行查询。正如您在编辑的代码中看到的那样,我对其进行了测试,但结果相同。很抱歉我的问题。。。