CBMutableCharacteristic

CBMutableCharacteristic

本文介绍了如何使用多个CBCharacteristicProperties和Permission初始化CBMutableCharacteristic的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在创建一个新的CBMutableCharacteristic,用于正在制作的Bluetooth应用中。我从一个教程中获得了一些代码,如下所示:

I'm creating a new CBMutableCharacteristic for use in a Bluetooth app I'm making. I got some code from a tutorial, which looks like this:

_customCharacteristic = [[CBMutableCharacteristic alloc] initWithType:characteristicUUID属性:CBCharacteristicPropertyNotify值:无权限:CBAttributePermissionsReadable];

其中 _customCharacteristic 是我的CBMutableCharacteristic。

where _customCharacteristic is my CBMutableCharacteristic.

但是,我想用其他属性(例如 CBCharacteristicPropertyRead _customCharacteristic c>和 CBCharacteristicPropertyWrite 。权限也是如此:我也想给它 CBAttributePermissionsWriteable

However, I want to initialize my _customCharacteristic with other properties, such as CBCharacteristicPropertyRead and CBCharacteristicPropertyWrite. The same is true for the permissions: I want to also give it CBAttributePermissionsWriteable.

据此:

和以下内容:

我可以同时具有多个属性和每个特征的权限。但是,我不知道如何以这种方式初始化CBMutableCharacteristic。

I can have both multiple properties and permissions for each characteristic. However, I don't know how to initialize my CBMutableCharacteristic in this way.

推荐答案

它是一个枚举,其不同值可以按位进行OR运算,因此可以一起使用特征属性和权限:

Its an enum, whose different values can be ORed bitwisely, so you can use the characteristic properties and permissions together:

CBMutableCharacteristic *_customCharacteristic = [[CBMutableCharacteristic alloc] initWithType:characteristicUUID properties:CBCharacteristicPropertyNotify+CBCharacteristicPropertyRead
 value:nil permissions:CBAttributePermissionsReadable|CBAttributePermissionsWriteable];

这篇关于如何使用多个CBCharacteristicProperties和Permission初始化CBMutableCharacteristic的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 17:22