我有代碼,我想獲得PFUser的用戶名。我得到用戶並能夠打印出來,但是當我到達用戶名的行時,代碼就停止了。沒有碰撞沒有,只是停止運行?獲取用戶名的解析用戶
任何想法,爲什麼會這樣做?
print(employeeObject)
firstName.text = employeeObject.firstName
lastName.text = employeeObject.lastName
if employeeObject.roleType != nil {
roleLabel.text = employeeObject.roleType?.roleName
}
if employeeObject.objectForKey("userPointer") != nil {
employeeObject.userPoint = employeeObject.objectForKey("userPointer") as! PFUser
}
if employeeObject.userPoint != nil {
let userID = employeeObject.userPoint!.objectId!
let query = PFUser.query()
query?.whereKey("objectId", equalTo: userID)
query?.getFirstObjectInBackgroundWithBlock({ (userData : PFObject?, error : NSError?) in
print(userData)
self.userLoginSwitch.setOn(true, animated: false)
self.userNameTextField.text = self.employeeObject.userPoint?.username!
self.passwordTextField.text = ""
self.emailAddressTextField.text = self.employeeObject.userPoint!.email
if self.employeeObject.userPoint!.objectForKey("isAdmin") as! Bool {
self.adminSwitch.setOn(true, animated: false)
}
})
}
if employeeObject.active {
disableEnableEmployee.setTitle("Disable Employee", forState: .Normal)
} else {
disableEnableEmployee.setTitle("Enable Employee", forState: .Normal)
disableEnableEmployee.setTitleColor(UIColor.blueColor(), forState: .Normal)
}
我userPoint鑄成一個PFUser,然後在解析我有它指向用戶表,當我打印。我可以看到所有的信息。它只是停止工作思想,沒有錯誤或解釋。
var userPoint : PFUser? {
get {return objectForKey("userPointer") as? PFUser}
set { setObject(newValue!, forKey: "userPointer") }
}
然後你分類?顯示詳細資料。 – Wain