开发者

How to make a "0000001" NSString

开发者 https://www.devze.com 2023-03-06 23:55 出处:网络
Another noob question from me. I\'m trying to create an application that counts, and I\'d like to display the number value as som开发者_Go百科ething like \"000001\". So when it counts up it\'ll displa

Another noob question from me. I'm trying to create an application that counts, and I'd like to display the number value as som开发者_Go百科ething like "000001". So when it counts up it'll display as "000002".

I'm using something like this right now, but it's not working:

counter.text = [NSString stringWithFormat:@"%000f", count];

The counter.text is a UILabel.

Thanks for the answer.


If you're storing the number as an integer, use the %0xd format (where x is the number of digits) like so:

counter.text = [NSString stringWithFormat:@"%06d", count];


try this

NSLog(@"%.6d",3);

more info please refer to NSDataformatter.

0

精彩评论

暂无评论...
验证码 换一张
取 消