Parse.com - 来自 PFUser 对象的电子邮件尽管具有价值但获取了一个 nil

Parse.com - email from PFUser object fetches a nil despite having value

我有一个查询 "items" 对象。 class 有一个指向 _User 对象的 "parent" 键。

查询成功并获取 'parent' 对象,我可以从这个 'parent' 对象访问一些自定义键,但电子邮件返回为 nil ! 下面是精简代码。

谁能告诉我为什么会这样?这是较早的工作,我没有进行任何代码更改。 运行 Heroku 上的解析服务器版本 2.5.3。

     let query = PFQuery(className: "items")
     query.includeKey("parent") // parent points to _User


     do {

         let results = try query.findObjects()

         for result in results {

         let parent = result["parent"] as! PFUser

        let foundUser = User()
        foundUser.user = parent // User.user is of PFUser type

        //custom keys in _User
        foundUser.name = parent["name"] as! String 
        foundUser.city = parent["city"] as! String
        foundUser.geoLocation = parent["location_geopoint"] as! PFGeoPoint 
        foundUser.userAddress = parent["user_address"] as! String

        //this is failing with nil eventhough there is value in Parse
        foundUser.email = parent["email"] as! String

        // also tried this. parent.objectId returns a valid value
        foundUser.email = parent.email


       }

     } catch...

在这里得到答案enter link description here

In 2.3.0 there was a breaking change introduced which restricted the fields returned from a query on _User. If I remember correctly, email is taken out by default and you can specify additional fields to be removed from a query result in a configuration setting. In order to retrieve email you either have to specify the master key or be the owner of that object.