Matthew Chung Matthew Chung - 1 year ago 68
Swift Question

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

When debugging in Swift, I'm having problems reading out variables. In this example, I'm trying to print out the value of the

object coming back from an image picker. (please see link to screenshot on dropbox)

as you can see from the screenshot line 19 works fine. It prints out the first block of stuff on the output.

After that, I tried doing a
po info
as well as highlighting the variable and clicking the eye to print the description. Both of those printed out an empty
which doesn't make sense to me, since there is clearly stuff there.

So my question is, is there an lldb command or easy way to view/print out the values of the variables - opposed to an empty
I find I can't consistently observe the values of my variables which is frustrating.

Answer Source

Workaround for lldb limitations (example):

(lldb) p println(countryHash!)

Output example:

[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, ... ]