iOS Developer Library

Developer

CoreBluetooth Framework Reference CBMutableService Class Reference

Options
Deployment Target:

On This Page
Language:

CBMutableService

Inherits From


Conforms To


Import Statement


Swift

import CoreBluetooth

Objective-C

@import CoreBluetooth;

Availability


Available in iOS 6.0 and later

The CBMutableService class adds write access to all of the properties in the CBService class it inherits from. You use this class to create a service or an included service on a local peripheral device (represented by a CBPeripheralManager object). After you create a service, you can add it to the peripheral’s local database using the addService: method of the CBPeripheralManager class. After you add a service to the peripheral’s local database, the service is cached and you can no longer make changes to it.

  • Returns a newly initialized mutable service specified by UUID and service type.

    Declaration

    Swift

    init!(type UUID: CBUUID!, primary isPrimary: Bool)

    Objective-C

    - (instancetype)initWithType:(CBUUID *)UUID primary:(BOOL)isPrimary

    Parameters

    UUID

    A 128-bit UUID that identifies the service.

    isPrimary

    A Boolean value indicating whether the type of service is primary or secondary. If the value is YEStrue, the type of service is primary. If the value is NOfalse, the type of service is secondary.

    Return Value

    A newly initialized mutual service.

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Swift

    import CoreBluetooth

    Availability

    Available in iOS 6.0 and later

  • UUID UUID Property

    The Bluetooth-specific UUID of the service.

    Declaration

    Swift

    var UUID: CBUUID!

    Objective-C

    @property(retain, readwrite, nonatomic) CBUUID *UUID

    Discussion

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

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Swift

    import CoreBluetooth

    Availability

    Available in iOS 6.0 and later

  • isPrimary isPrimary Property

    A Boolean value indicating whether the type of service is primary or secondary.

    Declaration

    Swift

    var isPrimary: Bool

    Objective-C

    @property(readwrite, 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, while 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 of a service.

    Declaration

    Swift

    var characteristics: [AnyObject]!

    Objective-C

    @property(retain, readwrite) NSArray *characteristics

    Discussion

    An array containing 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 6.0 and later

  • A list of included services.

    Declaration

    Swift

    var includedServices: [AnyObject]!

    Objective-C

    @property(retain, readwrite) NSArray *includedServices

    Discussion

    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.

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Swift

    import CoreBluetooth

    Availability

    Available in iOS 6.0 and later