这是我的代码:

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”

最佳答案

我想这是因为[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
    }
}

关于ios - PFObject没有成员objectforkey,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34700434/

10-11 17:24