Skip navigation.
 
mlRe: An Octal number into a Textfield
FROM : Sherm Pendley
DATE : Tue Jun 13 17:15:05 2006

On Jun 13, 2006, at 8:55 AM, Andrew Knott wrote:

> Hi everyone,
>
> Just a quick one... I'm trying to get an NSTextField to display an 
> octal number
>
> If I have :
>
> fileMode = 0644;
>
> and set a textField with
>
> [octalField setStringValue: [[NSNumber 
> numberWithUnsignedLong:fileMode] stringValue]];
>
> I get only the decimal version of the number? How would I get an 
> octal representation? With a NSNumberFormatter perhaps? I don't 
> seem to be able to find any hints...


You could use the "%o" format with sprintf(), or NSString's -
stringWithFormat: to get the octal representation.

If you're using bindings your textField, or even just assigning a new 
value pretty often, a formatter is the way to go. But, you'll need to 
use the above suggestions in a subclass NSFormatter or 
NSNumberFormatter. As far as I know, neither one handles octal by 
default.

sherm--

Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

Related mailsAuthorDate
mlAn Octal number into a Textfield Andrew Knott Jun 13, 14:55
mlRe: An Octal number into a Textfield Shawn Erickson Jun 13, 17:08
mlRe: An Octal number into a Textfield Sherm Pendley Jun 13, 17:15