iOS Developer Library

Developer

CoreBluetooth Framework Reference CBService Class Reference

Options
Deployment Target:

On This Page
Language:

CBService

Inherits From


Conforms To


Import Statement


Swift

import CoreBluetooth

Objective-C

@import CoreBluetooth;

Availability


Available in iOS 5.0 and later

CBService and its subclass CBMutableService represent a peripheral’s service—a collection of data and associated behaviors for accomplishing a function or feature of a device (or portions of that device). CBService objects in particular represent services of a remote peripheral device (represented by a CBPeripheral object). Services are either primary or secondary and may contain a number of characteristics or included services (references to other services).

  • UUID UUID Available in iOS 5.0 through iOS 7.1 Property

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

    Declaration

    Objective-C

    @property(readonly, nonatomic) CBUUID *UUID

    Discussion

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

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Availability

    Available in iOS 5.0 through iOS 7.1

  • The peripheral to which this service belongs. (read-only)

    Declaration

    Swift

    weak var peripheral: CBPeripheral! { get }

    Objective-C

    @property(weak, readonly, nonatomic) CBPeripheral *peripheral

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Swift

    import CoreBluetooth

    Availability

    Available in iOS 5.0 and later

  • isPrimary isPrimary Property

    A Boolean value indicating whether the type of service is primary or secondary. (read-only)

    Declaration

    Swift

    var isPrimary: Bool { get }

    Objective-C

    @property(readonly, nonatomic) BOOL isPrimary

    Discussion

    A peripheral’s service is either primary or secondary. A primary service describes the primary function of a device and can be included by another service. A secondary service describes a service that is relevant only in the context of another service that has referenced it. For example, the primary service of a heart rate monitor may be to expose heart rate data from the monitor’s heart rate sensor, whereas a secondary service may be to expose the sensor’s battery data. If the value of this property is YEStrue, the type of service is primary. If the value of this property is NOfalse, the type of service is secondary.

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Swift

    import CoreBluetooth

    Availability

    Available in iOS 6.0 and later

  • A list of characteristics that have been discovered in this service. (read-only)

    Declaration

    Swift

    var characteristics: [AnyObject]! { get }

    Objective-C

    @property(retain, readonly) NSArray *characteristics

    Discussion

    This array contains CBCharacteristic objects that represent a service’s characteristics. Characteristics provide further details about a peripheral’s service. For example, a heart rate service may contain one characteristic that describes the intended body location of the device’s heart rate sensor and another characteristic that transmits heart rate measurement data.

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Swift

    import CoreBluetooth

    Availability

    Available in iOS 5.0 and later

  • A list of included services that have been discovered in this service. (read-only)

    Declaration

    Swift

    var includedServices: [AnyObject]! { get }

    Objective-C

    @property(retain, readonly) NSArray *includedServices

    Discussion

    This array contains CBService objects that represent the included services of a service. A service of a peripheral may contain a reference to other services that are available on the peripheral. These other services are the included services of the service and can be discovered using the discoverIncludedServices:forService: method of the CBPeripheral class.

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Swift

    import CoreBluetooth

    Availability

    Available in iOS 5.0 and later