作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
尝试使用扫描仪时,我收到警告,称“scanLocation”在iOS 13.0中已弃用。由于能够从下一个位置进行扫描对于扫描String至关重要,因此想知道使用什么代替scanLocation。苹果公司针对Scanner的文档甚至没有提到过时,更不用说什么代替了scanLocation。
不推荐使用scanLocation的示例:
while !scanner.isAtEnd {
print(scanner.scanUpToCharacters(from: brackets))
let block = scanner.string[scanner.currentIndex...]
print(block)
scanner.scanLocation = scanner.scanLocation + 1
}
最佳答案
tl; dr-在Swift中使用currentIndex
时,请使用scanLocation
代替Scanner
。
对于可怜的文档,Apple感到羞耻。但是基于NSScanner.h文件中有关Scanner的Objective-C版本的信息,仅在Swift中,不赞成使用scanLocation
属性,并用currentIndex
属性代替。
关于swift - 如何解决 'scanLocation'在iOS 13.0中已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58754445/
我是一名优秀的程序员,十分优秀!