When trying to use a Scanner I am getting the warning that 'scanLocation' was deprecated in iOS 13.0. Since being able to scan from the next location is rather fundamental to scanning a String, wondering what to use instead of scanLocation. Apple's documentation for Scanner does not even mention the deprecation, let alone suggest what has taken the place of scanLocation.
Example of using scanLocation, which is deprecated:
while !scanner.isAtEnd {
print(scanner.scanUpToCharacters(from: brackets))
let block = scanner.string[scanner.currentIndex...]
print(block)
scanner.scanLocation = scanner.scanLocation + 1
}
tl;dr - use currentIndex
instead of scanLocation
when using Scanner
in Swift.
Shame on Apple for the poor documentation. But based on information in the NSScanner.h file for the Objective-C version of Scanner, only in Swift, the scanLocation
property has been deprecated and replaced with the currentIndex
property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With