ios - 带有 Parse 对象的 Swift Update 标签

标签 ios swift parse-platform uilabel

我正在尝试使用解析对象的内容更新标签。这是行不通的。

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/

相关文章:

iOS 访问 nowPlayingInfo post 到 web service

ios - 为什么表格 View 的大小与 iPhone X~iPhone XS Max 不同?

javascript - 将列表传递给 Parse.Promise.when 但仅获取 promise 链中的第一个元素

html - 突然我的 Parse 应用程序停止读取一些 Css 文件

iOS Sqlite 数据库不显示第一条记录

ios - 具有自动布局的 UITableView 页脚和页眉的奇怪位置

ios - 如何将 SKSpriteNode 保存为 PNG 图像到相机胶卷?

ios - 解析iOS SDK : Refresh PFQueryTableViewController upon new object

android - Firebase 远程配置值的自定义验证逻辑?

ios - 在单一应用程序模式下静默更新 iOS 企业应用程序