【问题标题】:quantityType(forIdentifier:) deprecated in a future version of iOS?在未来的 iOS 版本中不推荐使用 quantityType(forIdentifier:)?
【发布时间】:2022-01-10 13:35:10
【问题描述】:

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

因此,我检查了Apple's developer documentation 以提示还有什么可以使用的。令人惊讶的是,在文档中它并没有被标记为在不久的将来被弃用。

在这种情况下可以信任哪个来源?如果quantityType(forIdentifier:) 将来确实要被删除,是否已经有已知的替代品?

【问题讨论】:

  • 不知道为什么这个问题被否决了,所以把它提高了。救了我发布同样的问题!

标签: swift deprecated healthkit deprecation-warning apple-documentation


【解决方案1】:

代码完成对话框只是报告您在查看与它正在查看的相同标题时可以看到的内容:

@available(iOS, introduced: 8.0, deprecated: 100000)
open class func quantityType(forIdentifier identifier: HKQuantityTypeIdentifier) -> HKQuantityType?

100000 表示“未知的未来”。不用着急;这只是一个警告。

但您不妨现在就开始更新您的代码。替换将是这个初始化器:

https://developer.apple.com/documentation/healthkit/hkquantitytype/3778608-init

【讨论】:

  • 我不知道如何解释 100000。Apple 自己的文档中的几乎所有示例代码都使用“已弃用”版本。又学到了一些东西!谢谢;)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多