我想获取特定配件的可更新特性的值。
所以我正在使用 func accessory(accessory: HMAccessory!, service: HMService!, didUpdateValueForCharacteristic characteristic: HMCharacteristic!)
方法。
但是这个方法并没有被调用。正在调用来自同一委托(delegate)的另一个方法。应该是什么问题?
最佳答案
为 viewWillAppear 中的特征启用通知。
for (HMCharacteristic *thisCharacteristic in characteristicsArray) {
if ([thisCharacteristic.properties containsObject:HMCharacteristicPropertySupportsEventNotification]) {
[thisCharacteristic enableNotification:TRUE completionHandler:^(NSError *error) {
if (error) {
NSLog(@"Error while enabling notification");
}
else {
NSLog(@"Notification enabled");
}
}];
}
同时禁用 viewWillDisappear 中的通知
关于ios - 未调用 HMAccessoryDelegate 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29117848/