Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a "0000001" type number format?

I want to generate incremental receipt numbers like this format "00000001". Every time new transaction happen, receipt number should increase by 1.

0000001
0000002
0000003

0000010
0000011

0000100
0000101

So, how could I implement this type of number format. Is there any special number formats in objective C?

like image 546
smartsanja Avatar asked Jan 16 '12 04:01

smartsanja


1 Answers

If your numbers are integers and only the output matters, you can do:

NSString * output = [NSString stringWithFormat:@"%07d", integer];

to have the number be formatted with 7 digits, leading zeroes.

like image 158
Peter Sarnowski Avatar answered Oct 03 '22 17:10

Peter Sarnowski