Vladimir Stazhilov
Vladimir Stazhilov

Reputation: 1954

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

Upvotes: 1

Views: 1737

Answers (1)

KevinDTimm
KevinDTimm

Reputation: 14376

How about "%02d" ?

or "%02i" ?

(See man printf for formatting information or cocoadev NSLOG)

Upvotes: 10

Related Questions