gpt4 book ai didi

swift - 如何解决 'scanLocation'在iOS 13.0中已弃用

转载 作者:行者123 更新时间:2023-12-04 15:05:57 25 4
gpt4 key购买 nike

尝试使用扫描仪时,我收到警告,称“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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com