Hey I'm making a timer app that has both minutes and seconds. To do this I am using two different labels. How can I make sure it is always two digits (10:01 not 10:1).
Thanks in advance.
Thanks in advance.
If the number is less than 10 put a 0 in front of it. Just always convert the int to NSString and put it in the label that way.
What have you tried so far?I thought of that too but it seems like there would be a more official way of doing it.
NSString* s = [NSString stringWithFormat:@"%02d", someInt];
Code:NSString* s = [NSString stringWithFormat:@"%02d", someInt];
man printf
http://www.opengroup.org/onlinepubs/009695399/functions/printf.html
Bad idea. Copying-and-pasting is not programming.I'll use it even if I don't understand it.