string format mask using xcode

Dear all,

i need to show numbers in label using xcode i managed to do this but i need this two decimal digits like 01 , 02 or 03 anything like that how we can do this using xcode.

Best regards
deniro1974Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
mad_macConnect With a Mentor Commented:
[NSString stringWithFormat:@"A zero padded integer: %02d", 2];

Open in new window

0
 
SpeedyApocalypseConnect With a Mentor Commented:
If you want to get 2 decimal digits from a float, you can use "0.2f".

For example:

[NSString stringWithFormat:@"A formatted float: 0.2f",84.246424];

Open in new window

0
 
deniro1974Author Commented:

OK thanks but what if i want to show any integer as two digits like if 1 will show 01 if 2 will show 02 if 10 will be 10 no change, i want it for integer.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.