Scanner
A string parser that scans for substrings or characters in a character set, and for numeric values from decimal, hexadecimal, and floating-point representations.
Declaration
class ScannerOverview
A 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 charactersToBeSkipped 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 scanner.string.substring(from: scanner.scanLocation).
Topics
Creating a Scanner
Getting a Scanner’s String
Configuring a Scanner
Scanning Characters and Strings
Scanning Numeric Values
scanDecimal(_:)scanDouble(_:)scanFloat(_:)scanHexDouble(_:)scanHexFloat(_:)scanHexInt32(_:)scanHexInt64(_:)scanInt(_:)scanInt32(_:)scanInt64(_:)scanUnsignedLongLong(_:)
Monitoring Scanner Progress
Instance Properties
Instance Methods
scanCharacter()scanCharacters(from:)scanDecimal()scanDouble(representation:)scanFloat(representation:)scanInt(representation:)scanInt32(representation:)scanInt64(representation:)scanString(_:)scanUInt64(representation:)scanUpToCharacters(from:)scanUpToString(_:)