PFObject没有成员objectforkey

时间:2016-01-10 00:03:09

标签: ios swift parse-platform

这是我的代码:

override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)

    state = .DefaultMode

    // fill the cache of a user's followees
    ParseHelper.getFollowingUsersForUser(PFUser.currentUser()!) { (results: [PFObject]?, error: NSError?) -> Void in
        let relations = results
        // use map to extract the User from a Follow object
        self.followingUsers = relations.map {
            $0.objectForKey(ParseHelper.ParseFollowToUser) as! PFUser
        }
    }
}

我的错误:

  

类型的价值' [PFObject]'没有会员' objectForKey'

1 个答案:

答案 0 :(得分:0)

我猜它是因为[PFObjects]数组是可选的,还没有解开。

if let relations = results {
    // use map to extract the User from a Follow object
    self.followingUsers = relations.map {
        $0.objectForKey(ParseHelper.ParseFollowToUser) as! PFUser
    }
}