discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: zero padding numbers


From: tgate
Subject: Re: zero padding numbers
Date: Sat, 18 Nov 2006 09:11:36 -0800


On Nov 18, 2006, at 7:49 AM, Graham J Lee wrote:

On 18 Nov 2006, at 06:52, tgate wrote:

I notice that in Cocoa the NSNumberFormatter class has a method for setting a "pad" so that numbers like "12" can look like "0012" after formating. This seems to be missing from the GNUstep version and I'm wondering if there is another way people tend to do this. If I want to read a series of images uploaded form a camera the zero-pad is very helpful.

If you mean -paddingCharacter and -setPaddingCharacter: these are only available with NSNumberFormatterBehavior10_4 and GNUstep's NSNumberFormatter doesn't implement that behaviour at all. However you can do what you want in the 'original' NSNumberFormatter anyway:

NSNumberFormatter *fmt=[[[NSNumberFormatter alloc] init] autorelease];
        [fmt setFormat:@"0000"];
        [[textField cell] setFormatter:fmt];

I didn't realize that, thank you. Will this work in a non-gui situation as well? I have a command line tool where I submit start and end frames as an argument but internally I want to pad them out. It doesn't seem that the NSNumber class has a setFormatter: method however.

-todd





reply via email to

[Prev in Thread] Current Thread [Next in Thread]