2016-05-04 45 views
1

如何在Swift中使用Parse從查詢指針內部的指針訪問值?如何使用Parse在swift中查詢查詢指針內的指針值?

這與Parse中的三個類有關。一個是Post_Story,一個是Post,一個是User。當我查詢Post_Story時,我能夠從「Post」鍵中檢索指針信息,但是有什麼方法可以從該指針內的指針訪問信息嗎? (鑰匙「createdBy」到User類)

我的代碼如下所示:

 let postQuery = PFQuery(className: "Post_Story") 
    postQuery.whereKey("story", containedIn: storyObjects) 
    postQuery.includeKey("post") 

    postQuery.findObjectsInBackgroundWithBlock { (objects:[PFObject]?, error:NSError?) in 
     if error == nil { 
      for object in objects! { 
       if let postL = object["post"] as? PFObject { 

        if postL["createdBy"] != nil { 

         //this is where I want to get infor from PFUser, but not all info is sent 
         print((postL["createdBy"] as! PFUser)) //prints PFUser object without username etc. 

        } 
       } 
      } 
     } 
     else {} 
    } 

我希望這個問題不是太傻了

回答

2

您可以添加postQuery.includeKey("post.createdBy")包括用戶對象在列post

+0

謝謝!這工作像黃油。 – b3rge