【问题标题】:SwiftyJSON can't get to stringSwiftyJSON 无法获取字符串
【发布时间】:2015-01-08 07:08:22
【问题描述】:

我在这里做错了什么。我正在使用 SwiftyJSON。第一行打印正确的值。我在第二行收到一条错误消息:找不到成员字符串。我不应该能够在这里获取字符串值吗?

println(json["weather"][0]["description"])    // prints the correct value
if let description = json["weather"][0]["description"].string {
    self.descriptionLabel.text = description
}

【问题讨论】:

  • 你为什么要做.string??就做let description = json["weather"][0]["description"]
  • 你可能在一个不起作用的字符串上调用 .string,删除 .string

标签: json swift swifty-json


【解决方案1】:

试试这个

descriptionLabel.text = json["weather"][0]["description"].stringValue

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-22
    • 2020-05-16
    • 2016-06-30
    相关资源
    最近更新 更多