2
PFUser.logInWithUsernameInBackground(fullName.text, password: password.text) {
(user: PFUser!, error: NSError!) -> Void in

     if user != nil {

       self.loginButton.enabled = false
       self.helpButton.enabled = false

       self.objectID = self.PFUser.objectId
    }
}

我需要用户登录后的 objectID。当涉及到 PFUser 时,我知道如何检索 PFObject 的 objectID(在上面的最后一行代码中)。我怎样才能得到身份证?

4

2 回答 2

2

您正在使用self.PFUser.objectId,但我认为您的意思user是您从完成块中返回。所以试试:

self.objectID = user.objectId

在最后一行。

于 2015-02-15T16:06:44.113 回答
1

您应该使用user.objectIdPFUser.currentUser().objectId代替self.PFUser.objectId

self.objectID = user.objectId
self.objectID = PFUser.currentUser().objectId
于 2015-02-15T16:11:38.490 回答