swift - 数量类型(标识符 :) deprecated in a future version of iOS?

标签 swift deprecated healthkit deprecation-warning apple-documentation

Xcode(我使用的是 v13.1)警告我,quantityType(forIdentifier:) 将在未来的 iOS 版本中弃用。

enter image description here

我因此 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/

相关文章:

ios - 如何打开 "Add Widgets"从应用程序查看

ios - 使用谷歌地图和 Swift 的当前位置

javascript - EmberJs 弃用组件生命周期钩子(Hook) didReceiveAttrs

angular - 如何将组件选择器标记为已弃用?

android - GestureDetector 已弃用的问题

ios - 在我的应用程序中存储HealthKit数据

swift - hkanchoredObjectQuery UpdateHandler仅调用一次

ios - 如何使用 MVVM 处理 UITableViewCell 中的 UICollectionView

ios - Swift HealthKit 更新生日

ios - 如何在 Swift 中声明返回自定义结构序列的方法