【问题标题】:How to resolve 'scanLocation' was deprecated in iOS 13.0?如何解决 iOS 13.0 中已弃用的“scanLocation”?
【发布时间】:2021-12-06 07:48:43
【问题描述】:

在尝试使用扫描仪时,我收到警告说“scanLocation”在 iOS 13.0 中已被弃用。Apple 的 Scanner 文档甚至没有提到弃用,更不用说建议什么取代了 scanLocation。

使用 scanLocation 的示例,已弃用:

convenience init(hexString: String) {
        let scanner = Scanner(string: hexString)
        scanner.scanLocation = 0   // 'scanLocation' was deprecated in iOS 13.0
        var rgbValue: UInt64 = 0
        scanner.scanHexInt64(&rgbValue)
}

【问题讨论】:

    标签: deprecated ios13


    【解决方案1】:

    您可以使用currentIndex 代替scanLocation

    scanner.currentIndex = hexString.startIndex
    

    【讨论】:

      猜你喜欢
      • 2020-03-04
      • 2019-11-29
      • 1970-01-01
      • 2020-01-12
      • 2020-09-07
      • 1970-01-01
      • 2020-07-26
      相关资源
      最近更新 更多