Swift 使用 Parse 对象更新标签
Swift Update label with Parse object
我正在尝试使用解析对象的内容更新标签。这不起作用。
if let userPoints = PFUser.currentUser()?["points"] as? String {
self.userPointsLabel.text = userPoints
}
虽然这里有效
if let pUserName = PFUser.currentUser()?["username"] as? String {
self.userNameLabel.text = "@" + pUserName
}
积分列在用户 class 中,所以我不明白为什么这不起作用。
你在尝试施法和智力?字符串?并且失败了,所以 if 语句永远不会为真。
您想将点值解析为 Int,然后将其作为字符串使用
if let userPoints = PFUser.currentUser()?["points"] as? Int {
self.userPointsLabel.text = "\(userPoints)"
}
我正在尝试使用解析对象的内容更新标签。这不起作用。
if let userPoints = PFUser.currentUser()?["points"] as? String {
self.userPointsLabel.text = userPoints
}
虽然这里有效
if let pUserName = PFUser.currentUser()?["username"] as? String {
self.userNameLabel.text = "@" + pUserName
}
积分列在用户 class 中,所以我不明白为什么这不起作用。
你在尝试施法和智力?字符串?并且失败了,所以 if 语句永远不会为真。
您想将点值解析为 Int,然后将其作为字符串使用
if let userPoints = PFUser.currentUser()?["points"] as? Int {
self.userPointsLabel.text = "\(userPoints)"
}