iOS Developer Library

Developer

CoreBluetooth Framework Reference CBCharacteristic Class Reference

Options
Deployment Target:

On This Page
Language:

CBCharacteristic

CBCharacteristic and its subclass CBMutableCharacteristic represent further information about a peripheral’s service. CBCharacteristic objects in particular represent the characteristics of a remote peripheral’s service (remote peripheral devices are represented by CBPeripheral objects). A characteristic contains a single value and any number of descriptors describing that value. The properties of a characteristic determine how the value of the characteristic can be used and how the descriptors can be accessed.

Inheritance


Conforms To


Import Statement


Swift

import CoreBluetooth

Objective-C

@import CoreBluetooth;

Availability


Available in iOS 5.0 and later.
  • UUID UUID Available in iOS 5.0 through iOS 7.1 Property

    The Bluetooth-specific UUID of the characteristic. (read-only)

    Declaration

    Objective-C

    @property(readonly, nonatomic) CBUUID *UUID

    Discussion

    This property is a 128-bit UUID that identifies the characteristic.

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Availability

    Available in iOS 5.0 through iOS 7.1.

  • service service Property

    The service that this characteristic belongs to. (read-only)

    Declaration

    Swift

    weak var service: CBService! { get }

    Objective-C

    @property(weak, readonly, nonatomic) CBService *service

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Swift

    import CoreBluetooth

    Availability

    Available in iOS 5.0 and later.

  • value value Property

    The value of the characteristic. (read-only)

    Declaration

    Swift

    var value: NSData! { get }

    Objective-C

    @property(retain, readonly) NSData *value

    Discussion

    This property contains the value of the characteristic. For example, a temperature measurement characteristic of a health thermometer service may have a value that indicates a temperature in Celsius.

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Swift

    import CoreBluetooth

    Availability

    Available in iOS 5.0 and later.

  • A list of the descriptors that have been discovered in this characteristic. (read-only)

    Declaration

    Swift

    var descriptors: [AnyObject]! { get }

    Objective-C

    @property(retain, readonly) NSArray *descriptors

    Discussion

    The value of this property is an array of CBDescriptor objects that represent a characteristic’s descriptors. Characteristic descriptors provide more information about a characteristic’s value. For example, they may describe the value in human-readable form and describe how the value should be formatted for presentation purposes. For more information about characteristic descriptors, see CBDescriptor Class Reference.

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Swift

    import CoreBluetooth

    Availability

    Available in iOS 5.0 and later.

  • The properties of the characteristic. (read-only)

    Declaration

    Swift

    var properties: CBCharacteristicProperties { get }

    Objective-C

    @property(readonly, nonatomic) CBCharacteristicProperties properties

    Discussion

    The properties of a characteristic determine how the characteristic’s value and descriptors can be used and accessed. For a list of the possible values representing the properties of a characteristic, see Characteristic Properties.

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Swift

    import CoreBluetooth

    Availability

    Available in iOS 5.0 and later.

  • A Boolean value indicating whether the characteristic is currently notifying a subscribed central of its value. (read-only)

    Declaration

    Swift

    var isNotifying: Bool { get }

    Objective-C

    @property(readonly) BOOL isNotifying

    Discussion

    YEStrue if you have enabled notifications or indications for the characteristic by successfully calling the setNotifyValue:forCharacteristic: method of the CBPeripheral class. If the value of this property is YEStrue, the peripheral updates the subscribed central that it is connected to whenever the characteristic’s value has changed. If the value of the property is NOfalse, notifications (or indications) have not been enabled for the characteristic, and the peripheral does not update the central that it is connected to whenever the characteristic’s value has changed.

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Swift

    import CoreBluetooth

    Availability

    Available in iOS 5.0 and later.

  • isBroadcasted isBroadcasted (iOS 8.0) Property

    You should not use this property. (read-only)

    Declaration

    Swift

    var isBroadcasted: Bool { get }

    Objective-C

    @property(readonly) BOOL isBroadcasted

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Swift

    import CoreBluetooth

    Availability

    Available in iOS 5.0 and later.

    Deprecated in iOS 8.0.

  • Values representing the possible properties of a characteristic. Since characteristic properties can be combined, a characteristic may have multiple property values set.

    Declaration

    Swift

    struct CBCharacteristicProperties : RawOptionSetType { init(_ rawValue: UInt) init(rawValue rawValue: UInt) static var Broadcast: CBCharacteristicProperties { get } static var Read: CBCharacteristicProperties { get } static var WriteWithoutResponse: CBCharacteristicProperties { get } static var Write: CBCharacteristicProperties { get } static var Notify: CBCharacteristicProperties { get } static var Indicate: CBCharacteristicProperties { get } static var AuthenticatedSignedWrites: CBCharacteristicProperties { get } static var ExtendedProperties: CBCharacteristicProperties { get } static var NotifyEncryptionRequired: CBCharacteristicProperties { get } static var IndicateEncryptionRequired: CBCharacteristicProperties { get } }

    Objective-C

    typedef enum { CBCharacteristicPropertyBroadcast = 0x01, CBCharacteristicPropertyRead = 0x02, CBCharacteristicPropertyWriteWithoutResponse = 0x04, CBCharacteristicPropertyWrite = 0x08, CBCharacteristicPropertyNotify = 0x10, CBCharacteristicPropertyIndicate = 0x20, CBCharacteristicPropertyAuthenticatedSignedWrites = 0x40, CBCharacteristicPropertyExtendedProperties = 0x80, CBCharacteristicPropertyNotifyEncryptionRequired = 0x100, CBCharacteristicPropertyIndicateEncryptionRequired = 0x200, } CBCharacteristicProperties;

    Constants

    • Broadcast

      CBCharacteristicPropertyBroadcast

      The characteristic’s value can be broadcast using a characteristic configuration descriptor.

      This property is not allowed for local characteristics published via the addService: method of the CBPeripheralManager class. This means that you cannot use this property when you initialize a new CBMutableCharacteristic object via the initWithType:properties:value:permissions: method of the CBMutableCharacteristic class.

      Available in iOS 5.0 and later.

    • Read

      CBCharacteristicPropertyRead

      The characteristic’s value can be read.

      Use the readValueForCharacteristic: method of the CBPeripheral class to read the value of a characteristic.

      Available in iOS 5.0 and later.

    • WriteWithoutResponse

      CBCharacteristicPropertyWriteWithoutResponse

      The characteristic’s value can be written, without a response from the peripheral to indicate that the write was successful.

      Use the writeValue:forCharacteristic:type: method of the CBPeripheral class to write to a characteristic’s value, using the CBCharacteristicWriteWithoutResponse constant as the parameter for type:. If a characteristic has this property set, no error is sent back to the central when writing to the characteristic’s value is unsuccessful.

      Available in iOS 5.0 and later.

    • Write

      CBCharacteristicPropertyWrite

      The characteristic’s value can be written, with a response from the peripheral to indicate that the write was successful.

      If a characteristic has this property set, an error is sent to back to the central when writing to the characteristic’s value is unsuccessful. This property allows for values to be written to a characteristic’s value that are longer than those permitted by the CBCharacteristicPropertyWriteWithoutResponse constant. Use the writeValue:forCharacteristic:type: method of the CBPeripheral class to write to a characteristic’s value, using the CBCharacteristicWriteWithResponse constant as the parameter for type:.

      Available in iOS 5.0 and later.

    • Notify

      CBCharacteristicPropertyNotify

      Notifications of the characteristic’s value are permitted, without a response from the central to indicate that the notification was received.

      Available in iOS 5.0 and later.

    • Indicate

      CBCharacteristicPropertyIndicate

      Indications of the characteristic’s value are permitted, with a response from the central to indicate that the indication was received.

      Available in iOS 5.0 and later.

    • AuthenticatedSignedWrites

      CBCharacteristicPropertyAuthenticatedSignedWrites

      Signed writes of the characteristic’s value are permitted, without a response from the peripheral to indicate that the write was successful.

      If a characteristic has this property set, no error is sent back to the central when writing to the characteristic’s value is unsuccessful.

      Available in iOS 5.0 and later.

    • ExtendedProperties

      CBCharacteristicPropertyExtendedProperties

      Additional characteristic properties are defined in the characteristic extended properties descriptor.

      This property is not allowed for local characteristics published using the addService: method of the CBPeripheralManager class. That is, you cannot use this property when you initialize a CBMutableCharacteristic object using the initWithType:properties:value:permissions: method of the CBMutableCharacteristic class.

      Available in iOS 5.0 and later.

    • NotifyEncryptionRequired

      CBCharacteristicPropertyNotifyEncryptionRequired

      Only trusted devices can enable notifications of the characteristic’s value.

      Available in iOS 6.0 and later.

    • IndicateEncryptionRequired

      CBCharacteristicPropertyIndicateEncryptionRequired

      Only trusted devices can enable indications of the characteristic’s value.

      Available in iOS 6.0 and later.

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Swift

    import CoreBluetooth

    Availability

    Available in iOS 5.0 and later.