FROM : Trygve Inda
DATE : Tue Jul 18 23:54:11 2006
> On Jul 18, 2006, at 3:43 PM, Trygve Inda wrote:
>
>> I have an int that I want converted into a string but I want it
>> prefixed
>> with zeros to a fixed length. So.
>>
>> 1 = 00001
>> 2 = 00002
>>
>> 534 = 00534
>>
>> Basically the opposite of
>>
>> stringByPaddingToLength:withString:startingAtIndex:
>>
>> Is there a method to do this directly?
>
> NSString *foo = [NSString stringWithFormat:@"%5d", aSignedInt];
This results in strings like " 8" instead of "08".
Perhaps I need to add a category to NSString?
Trygve
DATE : Tue Jul 18 23:54:11 2006
> On Jul 18, 2006, at 3:43 PM, Trygve Inda wrote:
>
>> I have an int that I want converted into a string but I want it
>> prefixed
>> with zeros to a fixed length. So.
>>
>> 1 = 00001
>> 2 = 00002
>>
>> 534 = 00534
>>
>> Basically the opposite of
>>
>> stringByPaddingToLength:withString:startingAtIndex:
>>
>> Is there a method to do this directly?
>
> NSString *foo = [NSString stringWithFormat:@"%5d", aSignedInt];
This results in strings like " 8" instead of "08".
Perhaps I need to add a category to NSString?
Trygve
| Related mails | Author | Date |
|---|---|---|
| Trygve Inda | Jul 18, 21:43 | |
| Sherm Pendley | Jul 18, 22:02 | |
| Trygve Inda | Jul 18, 23:54 | |
| j o a r | Jul 19, 00:00 | |
| stephen joseph but… | Jul 19, 00:00 | |
| Trygve Inda | Jul 19, 00:02 | |
| Robert Walker | Jul 19, 00:10 | |
| Matt Neuburg | Jul 19, 02:06 | |
| Trygve Inda | Jul 19, 11:14 |






Cocoa mail archive

