當配置CBMutableCharacteristic以將iOS設備設置爲外設時,CBCharacteristicProperties的可能值之一是CBCharacteristicPropertyBroadcast。CBCharacteristicPropertyBroadcast的用途
但是,如果你選擇了它,在運行時你會得到:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'CBCharacteristicPropertyBroadcast is not allowed'
我創建的特徵是這樣的:
let characteristic = CBMutableCharacteristic(type: myCharacteristicUUID,
properties: CBCharacteristicProperties.Broadcast,
value: characteristicValue,
permissions: CBAttributePermissions.Readable)
什麼是CBCharacteristicPropertyBroadcast
的目的是什麼? CBCharacteristicPropertyRead
和CBCharacteristicPropertyNotify
工作,但我想知道爲什麼我不能使用其他值。
理想情況下,我想將用戶數據作爲外設廣播而不用作信標。這是可行的嗎?
請注意,如果您在創建特徵時指定了值,則無法對其進行更改。您需要指定nil作爲初始值,然後根據需要更新它,以便能夠更改數據。 – Paulw11
啊對 - 謝謝。我現在意識到了。 –