标签:evel val handler discuss 详细 char develop 苹果 null
最近在研究HomeKit,在更改某个特征值的时候:
当设置了HMAccessoryDelegate的delegate后,在App中,改变HMCharacteristic的特征值时,
- (void)writeValue:(nullable id)value completionHandler:(void (^)(NSError * __nullable error))completion;
代理方法
- (void)accessory:(HMAccessory *)accessory service:(HMService *)service didUpdateValueForCharacteristic:(HMCharacteristic *)characteristic
是不会被触发的。
那么该方法在什么时候被触发呢?当App运行时,特征值被从他的途径修改的时候,比如通过设备的物理开关,才会触发App的改代理方法,目的是App UI与设备保持一致。
详细可参见苹果官方的描述:
Discussion This method is called as a result of a change in value initiated by the accessory. Programmatic changes initiated by the app do not result in this method being called.
https://developer.apple.com/documentation/homekit/hmaccessorydelegate/1615286-accessory?language=objc
标签:evel val handler discuss 详细 char develop 苹果 null
原文地址:http://www.cnblogs.com/fphuang/p/7906394.html