Xcode(我使用的是 v13.1)警告我,quantityType(forIdentifier:)
将在未来的 iOS 版本中弃用。
我因此 checkin 了Apple's developer documentation提示还有什么可以使用。令人惊讶的是,在文档中它没有被标记为在不久的将来弃用。
在这种情况下应该相信哪个来源?如果将来确实要删除 quantityType(forIdentifier:)
,是否已经有已知的替代品?
最佳答案
代码完成对话框只是报告如果您查看它正在查看的相同 header ,您自己会看到什么:
@available(iOS, introduced: 8.0, deprecated: 100000)
open class func quantityType(forIdentifier identifier: HKQuantityTypeIdentifier) -> HKQuantityType?
100000
表示“未知的 future ”。不用着急;这只是一个警告。
但您不妨现在就开始更新您的代码。替换将是这个初始值设定项:
https://developer.apple.com/documentation/healthkit/hkquantitytype/3778608-init
extension HKQuantityType {
@available(iOS 15.0, watchOS 8.0, macOS 13.0, *)
public convenience init(_ identifier: HKQuantityTypeIdentifier)
}
关于swift - 数量类型(标识符 :) deprecated in a future version of iOS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70226922/