CBMutableDescriptor objects represent the descriptors of a local peripheral’s characteristic (local peripheral devices are represented by
You use the
CBMutableDescriptor class to create a local characteristic descriptor. After you create a descriptor and associate it with a local characteristic, you can publish it (along with the characteristic and local service to which it belongs) to the peripheral’s local database via the
addService: method of the
CBPeripheralManager class. After you publish a local descriptor, the descriptor is cached and you can no longer make changes to it.
There are six predefined types of descriptors that—along with their corresponding value types—are detailed in CBUUID Class Reference. That said, only two of these are currently supported when creating local, mutable descriptors: the characteristic user description descriptor and the characteristic format descriptor, represented by the
CBUUIDCharacteristicFormatString, respectively. The system automatically creates the characteristic extended properties descriptor and the client characteristic configuration descriptor, depending on the properties of the characteristic to which the descriptor belongs.
Returns a newly initialized mutable descriptor with a specified value.
- (id)initWithType:(CBUUID *)
The descriptor value to be cached. This value is required (that is, it must not be
nil) and cannot be updated dynamically after the descriptor has been published.
A newly initialized mutable descriptor.
The value type of
valuedepends on the type of descriptor.
The value type of a characteristic user description descriptor (
CBUUIDCharacteristicUserDescriptionString) is a string (an instance of
NSString) that can be used to provide a human-readable description of the characteristic’s value.
The value type of a characteristic format descriptor (
CBUUIDCharacteristicFormatString) is an
NSDataobject that can be used to specify how the characteristic’s value should be formatted for presentation purposes.
If you want to create a local characteristic format descriptor, the descriptor’s value must conform to the attribute value of the characteristic format descriptor as defined in the Bluetooth 4.0 specification, Volume 3, Part G, Section 184.108.40.206 (for more information, see Bluetooth 4.0 Characteristic Presentation Format).