How to resolve 'scanLocation' was deprecated in iOS 13.0
@rmaddy already gave the correct answer, but this shows how to increment the currentIndex
since it is different from just adding 1 to the scanLocation
.
while !scanner.isAtEnd {
print(scanner.scanUpToCharacters(from: brackets))
let block = scanner.string[scanner.currentIndex...]
print(block)
scanner.currentIndex = scanner.string.index(after: scanner.currentIndex)
}
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.