O'Reilly logo

Cocoa in a Nutshell by James Duncan Davidson, Michael Beam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

NSFormatter — Mac OS X 10.0

Synopsis

This class declares an abstract interface for objects that an instance of NSCell can use to create, interpret, and validate a textual representation of the cell’s contents that is suited for human readability. The Foundation framework provides two concrete classes that are used to format numeric and time and date values: NSNumberFormatter and NSDateFormatter.

image with no caption

@interface NSFormatter : NSObject <NSCoding, NSCopying>
                                  // Instance Methods
   - (NSAttributedString *)attributedStringForObjectValue:(id)obj 
                                 withDefaultAttributes:(NSDictionary *)attrs;
   - (NSString *)editingStringForObjectValue:(id)obj;
   - (BOOL)getObjectValue:(id *)obj 
                                 forString:(NSString *)string 
                                 errorDescription:(NSString **)error;
   - (BOOL)isPartialStringValid:(NSString *)partialString 
                                 newEditingString:(NSString **)newString
                                 errorDescription:(NSString **)error;
   - (BOOL)isPartialStringValid:(NSString **)partialStringPtr
                                 proposedSelectedRange:(NSRangePointer)proposedSelRangePtr 
                                 originalString:(NSString *)origString
                                 originalSelectedRange:(NSRange)origSelRange 
                                 errorDescription:(NSString **)error;
   - (NSString *)stringForObjectValue:(id)obj;
                                  // Methods Implementing NSCoding
   - (void)encodeWithCoder:(NSCoder *)aCoder;
   - (id)initWithCoder:(NSCoder *)aDecoder;
                                  // Methods Implementing NSCopying
   - (id)copyWithZone:(NSZone *)zone;

Subclasses

NSDateFormatter, NSNumberFormatter ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required