How to NSLog an Optional Int in Swift? -


nslog still around in swift, , offers extras not available println such timestamp, module, , thread.

however, i'm unsure how log optional, example optional int.

logging unwrapped optional works fine, e.g.

if let = myindex  {    nslog("%@ %d", __function__, i) } 

attempting log myindex, expect object therefore using format specifier %@;

nslog("%@ myindex %@", __function__, myindex) 

gives build error:

value of optional type 'int?' not unwrapped; did mean use '!' or '?'? 

how can use nslog - not println - console out optional int?

just use string interpolation syntax:

let d: int? = 5  nslog("\(d)") 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -