TextField number formatting

Discussion in 'Mac Programming' started by gaswerks, Mar 22, 2010.

  1. gaswerks macrumors 6502

    Joined:
    Dec 17, 2006
    #1
    XCode 3.1.3 Cocoa Application (Objective C)

    New to XCode. I am writing to a .xib TextField box "psat" through the following code;

    [psat setDoubleValue:p_sat];

    How do I apply a number format (i.e. %.2f or %.4g) to it?
     
  2. Sydde macrumors 68020

    Sydde

    Joined:
    Aug 17, 2009
    #2
    Have you tried (in Interface Builder) dragging a formatter onto the text field and setting it up?
     
  3. HiRez macrumors 603

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #3
    Or you can use NSString's stringWithFormat: method to do printf-style formatting.
     
  4. gaswerks thread starter macrumors 6502

    Joined:
    Dec 17, 2006
    #4
    Thanks

    Thanks for the formatter tip .. mission accomplished.
     

Share This Page