Search code examples
objective-cnslog

NSLog with 2 digits display


Here I have an

int x=3;

NSLog(@"%i", x);

How to have it displayed like "01"? and if x=12 to have it displayed like "12"? Thanks


Solution

  • How about "%02d" ?

    or "%02i" ?

    (See man printf for formatting information or cocoadev NSLOG)