我正在尝试使用解析对象的内容更新标签。这是行不通的。
if let userPoints = PFUser.currentUser()?["points"] as? String {
self.userPointsLabel.text = userPoints
}
不过这里可以用
if let pUserName = PFUser.currentUser()?["username"] as? String {
self.userNameLabel.text = "@" + pUserName
}
积分列在用户类中,所以我不明白为什么这不起作用。
最佳答案
你正在尝试施法和智力?字符串?并且失败了,所以 if 语句永远不会为真。
您想将点值解析为 Int,然后将其作为字符串使用
if let userPoints = PFUser.currentUser()?["points"] as? Int {
self.userPointsLabel.text = "\(userPoints)"
}
关于ios - 带有 Parse 对象的 Swift Update 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33860017/