2016-05-04 42 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