I have the following variable:
NSNumber *consumption = [dict objectForKey:@"con"];
Which returns 42. How can I pad this number to 10 digits on the left, leading with zeros. The output should look as,
0000000042
or if it were 420,
0000000420
I have the following variable:
NSNumber *consumption = [dict objectForKey:@"con"];
Which returns 42. How can I pad this number to 10 digits on the left, leading with zeros. The output should look as,
0000000042
or if it were 420,
0000000420
with variable num_digits
NSString* format =[NSString stringWithFormat:@"%%0%zdzd", num_digits];
NSString *theString = [NSString stringWithFormat:format, 42];