如何在 xcode 6.1.1 中打印出字典的值

How to print out the value of an an Dictionary in xcode 6.1.1

在 Swift 中调试时,我在读取变量时遇到问题。在这个例子中,我试图打印出从图像选择器返回的 info 对象的值。 (请参阅 link 到 dropbox 上的屏幕截图)

使用 println 正如您在屏幕截图第 19 行中看到的那样工作正常。它在输出中打印出第一块内容。

之后,我尝试做 po info 以及突出显示变量并单击眼睛以打印描述。两者都打印出一个空的 {},这对我来说没有意义,因为那里显然有东西。

所以我的问题是,是否有 lldb 命令或简单的方法来 view/print 输出变量的值 - 而不是空的 {} 我发现我无法始终如一地观察这些值我的变量令人沮丧。

https://dl.dropboxusercontent.com/u/45836281/debug.png

lldb 限制的解决方法(示例):

(lldb) p println(countryHash!)

输出示例:

[botswana: bw, united states minor outlying islands: um, isle of man: im, czech republic: cz, mauritius: mu, jersey: je, maldives: mv, uruguay: uy, barbados: bb, serbia: rs, qatar: qa, montenegro: me, grenada: gd, syrian arab republic: sy, samoa: ws, greenland: gl, iraq: iq, malawi: mw, croatia: hr, saint lucia: lc, seychelles: sc, egypt: eg, ... ]

(注意:国家列表实际上在 lldb 输出中是完整的,但只是在上面被截断以避免在这个答案中浪费 space)

在Swift2中是:

(lldb) p print(dict)

Swift 3

如果您不喜欢默认的 lldb 表示,您也可以:

(lldb) p dictionary.description