i have following variable:
nsnumber *consumption = [dict objectforkey:@"con"]; which returns 42. how can pad number 10 digits on left, leading zeros. output should as,
0000000042
or if 420,
0000000420
nsstring *paddedstr = [nsstring stringwithformat:@"%010d", 42]; edit: it's c style formatting. %nd means width @ least n. if integer 2 digit long, have length 3 string (when %3d used). default left empty spaces filled space. %0nd (0 between % , n) means 0 used padding instead of space. here n total length. if integer less n digits left padding used.
Comments
Post a Comment