我正在创建一个新的 CBMutableCharacteristic 以在我正在制作的蓝牙应用程序中使用。我从教程中得到了一些代码,如下所示:
_customCharacteristic = [[CBMutableCharacteristic alloc] initWithType:characteristicUUID properties:CBCharacteristicPropertyNotify value:nil permissions:CBAttributePermissionsReadable];
where _customCharacteristic
是我的 CBMutableCharacteristic。
但是,我想初始化我的_customCharacteristic
与其他属性,例如CBCharacteristicPropertyRead
and CBCharacteristicPropertyWrite
。权限也是如此:我也想给它CBAttributePermissionsWriteable
.
根据这个:http://developer.apple.com/library/ios/#documentation/CoreBluetooth/Reference/CBCharacteristic_Class/translated_content/CBCharacteristic.html#//apple_ref/doc/c_ref/CBCharacteristicProperties http://developer.apple.com/library/ios/#documentation/CoreBluetooth/Reference/CBCharacteristic_Class/translated_content/CBCharacteristic.html#//apple_ref/doc/c_ref/CBCharacteristicProperties
和这个:http://developer.apple.com/library/ios/#documentation/CoreBluetooth/Reference/CBMutableCharacteristic_Class/Reference/CBMutableCharacteristic.html#//apple_ref/doc/c_ref/CBAttributePermissions http://developer.apple.com/library/ios/#documentation/CoreBluetooth/Reference/CBMutableCharacteristic_Class/Reference/CBMutableCharacteristic.html#//apple_ref/doc/c_ref/CBAttributePermissions
我可以为每个特征拥有多个属性和权限。但是,我不知道如何以这种方式初始化我的 CBMutableCharacteristic。
它是一个枚举,其不同值可以按位或运算,因此您可以将特征属性和权限一起使用:
CBMutableCharacteristic *_customCharacteristic = [[CBMutableCharacteristic alloc] initWithType:characteristicUUID properties:CBCharacteristicPropertyNotify+CBCharacteristicPropertyRead
value:nil permissions:CBAttributePermissionsReadable|CBAttributePermissionsWriteable];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)