开发者

StringWithFormat min width

开发者 https://www.devze.com 2023-01-24 06:50 出处:网络
I know that this is possible, but can\'t seem to find it.I need to format a string (using stringWithFormat) with 3 0\'s when the value is <100.

I know that this is possible, but can't seem to find it. I need to format a string (using stringWithFormat) with 3 0's when the value is <100.

So my integer i = 5, the string should be @"005", but 开发者_如何转开发I can't remember or find the format specifier to make this happen.

Hopefully this is low hanging fruit.

Thanks!


All I had to do was ask:

%03d works great.

0

精彩评论

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