2014-10-23 6 views
2

"User"라는 구문 분석 클래스에 사용자가 있습니다.Swift : Parse.com에서 인버스 관계를 얻는 방법

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.... 

:

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

내가 사용자 1, 난이 특정 사용자가이 함께 따르는 것이 모든 사용자를 검색 할 수 있다고 가정하자 :

은이 같은 다른 사용자와 사용자의 PFRelation을 설정 사용자 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에 succesfull로드 사용자"저를 인쇄 만에 println (object.count)이 "0"저를 인쇄 할 수 있습니다. 나는 혼란스러워하는 물건이 있다는 것을 확신합니다 ...

답변

1

내장 된 사용자 클래스는 클래스 이름으로 "사용자"를 가지고 있지 않습니다. 내장 된 User 클래스를 쿼리하는 경우 "User"클래스를 쿼리하는 대신 PFUser's query method이 반환하는 PFQuery 객체를 사용해야합니다.

+0

수정 된 코드에서 볼 수있는 것처럼 테스트했지만 동일한 결과가 나타납니다. 멍청한 질문에 대해 유감으로 생각합니다 ... – jmcastel