加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

swift2 – XCode 7打印键和Dictionary的值

发布时间:2020-12-14 04:45:47 所属栏目:百科 来源:网络整理
导读:xcode 7中的打印描述给出了类似于下面的内存地址.尝试了所有选项,但得到这样的输出.请让我知道如何打印字典的确切值. ? 3 elements ? [0] : 2 elements - .0 : Output ? .1 : 3 elements ? [0] : 2 elements - .0 : type - .1 : Output2 { ... } ? [1] : 2 e
xcode 7中的打印描述给出了类似于下面的内存地址.尝试了所有选项,但得到这样的输出.请让我知道如何打印字典的确切值.

? 3 elements
  ? [0] : 2 elements
    - .0 : Output
    ? .1 : 3 elements
      ? [0] : 2 elements
        - .0 : type
        - .1 : Output2 { ... }
      ? [1] : 2 elements
        - .0 : version
        - .1 : 1.0
      ? [2] : 2 elements
        - .0 : content
        ? .1 : 2 elements

不确定为什么Apple 100%专注于控制台窗口..从XCode 5到6,6到6.2,6.2到6.4以及现在6.4到7都有变化.我认为Apple应该专注于提高质量而不是控制台)

解决方法

我创建了这个测试词典:

let dict:Dictionary = ["key1": "value1","key2": 42,"keyForColor": UIColor.redColor()]

然后我使用po dict并得到你描述的结果:

po dict
? 3 elements
  ? [0] : 2 elements
    - .0 : "key1"
    - .1 : value1
  ? [1] : 2 elements
    - .0 : "keyForColor"
  ? [2] : 2 elements
    - .0 : "key2"

当你使用po dict.description时,你得到这个:

po dict.description
"["key1": value1,"keyForColor": UIDeviceRGBColorSpace 1 0 0 1,"key2": 42]"

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读