迅速4-HMCharacteristicTypeSerialNumber已弃用 [英] swift 4 - HMCharacteristicTypeSerialNumber deprecated
问题描述
我想读取类型为HMAccessory
的附件的信息,例如序列号(HMCharacteristicTypeSerialNumber
),制造商(HMCharacteristicTypeManufacturer
),型号(HMCharacteristicTypeModel
),但根据iOS11,它们均已弃用此Apple文档此处.
I want to read information of an accessory, typed HMAccessory
, such as Serial number (HMCharacteristicTypeSerialNumber
), manufacturer (HMCharacteristicTypeManufacturer
), model (HMCharacteristicTypeModel
) but they all are deprecated in iOS11, according to this Apple doc here.
我知道我可以直接使用characteristicType
字符串,如下所示:
I know I can instead use the characteristicType
string directly, like below:
HMCharacteristicTypeSerialNumber
-> 00000030-0000-1000-8000-0026BB765291
HMCharacteristicTypeManufacturer
-> 00000020-0000-1000-8000-0026BB765291
HMCharacteristicTypeModel
-> 00000021-0000-1000-8000-0026BB765291
但是,这只会使我的代码不合常规",很难看.
But that just makes my code "unconventional", ugly.
您知道序列号,制造商和型号的特征类型的替代品吗?我已经搜索了几个小时,但仍然没有任何线索.
Do you know the replacements for the characteristic types of serial number, manufacturer and model? I have searched for hours but still no clues.
推荐答案
您已经注意到,从iOS 11.0开始,这些characteristicType
常量已被弃用.现在可以通过更新的HMAccessory
属性manufacturer
,model
和firmwareVersion
获得对制造商,型号和固件版本信息的访问.
As you noted, as of iOS 11.0, those characteristicType
constants have been deprecated. Access to manufacturer, model, and firmware version info is now obtained through the newer HMAccessory
properties manufacturer
, model
, and firmwareVersion
.
例如:
print("Manufacturer: \(accessory.manufacturer)")
print("Model: \(accessory.model)")
print("Firmware Version: \(accessory.firmwareVersion)")
但是,据我所见,虽然HMCharacteristicTypeSerialNumber
也已被弃用,但到目前为止HMAccessory
上没有任何属性可以访问此信息.
However, as far as I can see, while HMCharacteristicTypeSerialNumber
has also been deprecated, there isn't any property on HMAccessory
to access this info so far.
这篇关于迅速4-HMCharacteristicTypeSerialNumber已弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!