quantityType(forIdentifier:) deprecated in a future version of iOS?

1k Views Asked by At

Xcode (I'm on v13.1) warns me, that quantityType(forIdentifier:) will be deprecated in a future version of iOS.

enter image description here

I thus checked in Apple's developer documentation for a hint what else to use. Surprisingly, on the documentation it is not labeled as deprecated in near future.

Which source to trust in this case? And in case quantityType(forIdentifier:) is indeed to be removed in teh future, is there already a known replacement?

1

There are 1 best solutions below

3
On BEST ANSWER

The code completion dialog is merely reporting what you could see for yourself if you looked at the same header that it is looking at:

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

100000 means "the unknown future". There's no rush; it's only a warning.

But you might as well start updating your code now. The replacement will be this initializer:

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)
}