A string parser that scans for substrings or characters in a character set, and for numeric values from decimal, hexadecimal, and floating-point representations.
- iOS 2.0+
- macOS 10.0+
- tvOS 9.0+
- watchOS 2.0+
- Mac Catalyst 13.0+Beta
Scanner object interprets and converts the characters of a
String into number and string values. You assign the scanner’s string when you create the scanner, and the scanner progresses through the characters of that string from beginning to end as you request items.
Because of the nature of class clusters, a scanner object isn’t an actual instance of the
Scanner class, but is one of its private subclasses. Although a scanner object’s class is private, its interface is public, as declared by this abstract superclass,
Scanner. The objects you create using this class are referred to as scanner objects (and when no confusion will result, merely as scanners).
To set a
Scanner object to ignore a set of characters as it scans the string, use the
characters property. Characters in the skip set are skipped over before the target is scanned. The default set of characters to skip is the whitespace and newline character set.
To retrieve the unscanned remainder of the string, use