debugging - Viewing Swift optional values in debugger -
trying feet wet in writing , debugging swift code, wrote following. on os x 10.10.2, xcode 6.2.
let text : string? = "this text.\njust fun." let lines : [string]? = text?.componentsseparatedbycharactersinset( nscharacterset.newlinecharacterset()) println("\(lines)")
breaking on println ...
line, debugger's variable view shows some
value of lines
. in understanding, indicates lines
of optional type , contains value wrapped in some
, opposed being none
.
knowing that, how can use debugger inspect value is? tried:
- clicking small "i" button, produces output "some" in debugger console.
- entering
po lines
,po lines!
in debugger console, yieldsexc_bad_access
. update: following fresh installation of xcode,po lines
seems have no effect, i.e. no output.
the final line prints optional(["this text.", "just fun."])
, i'd debugger show.
how can @ unwrapped string array value of lines
, , difference between optional variable lines
, unwrapped value debugger doesn't show, , optional variable text
, value show? have introduce auxiliary variable every time want debug optional value, or use printf-debugging?
maybe misunderstanding, made "lines" optional value. because of that, need unwrap in println statement or not make optional value. take off "?" after "lines" declaration first , see if works you.
let lines : [string] =
Comments
Post a Comment