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

NSScanner — Mac OS X 10.0

Synopsis

This class declares an API for objects that can interpret and convert a string into individual number and string values. When you create a scanner object, you assign it the string to scan. Scanner objects are created with the method scannerWithString:, or initialized with initWithString:. A scanner works by interpreting and converting string and number values based on the scan message sent to the scanner object. For example, if the method scanInt: is invoked, the scanner will scan through the string searching from the next available integer. Scanning usually happens within a loop, until the entire string has been scanned. Clients can test whether or not the scanner is at the end of the string using the method isAtEnd.

image with no caption

@interface NSScanner : NSObject <NSCopying>
                                  // Convenience Constructors
   + (id)scannerWithString:(NSString *)string;
                                  // Initializers
   - (id)initWithString:(NSString *)string;
                                  // Accessor Methods
   - (void)setCaseSensitive:(BOOL)flag;
   - (BOOL)caseSensitive;
   - (void)setScanLocation:(unsigned)pos;
   - (unsigned)scanLocation;
   - (void)setCharactersToBeSkipped:(NSCharacterSet *)set;
   - (NSCharacterSet *)charactersToBeSkipped;
   - (void)setLocale:(NSDictionary *)dict;
   - (NSDictionary *)locale;
                                  // Class Methods
   + (id)localizedScannerWithString:(NSString *)string;
                                  // Instance Methods
   - (BOOL)scanCharactersFromSet ...

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