CBMutableService Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/CoreBluetooth.framework
Availability
Available in iOS 6.0 and later.
Companion guide
Declared in
CBService.h
Related sample code

Overview

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.

Tasks

Initializing a Mutable Service

Managing a Mutable Service

Properties

characteristics

A list of characteristics of a service.

@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.

Availability
  • Available in iOS 6.0 and later.
Declared In
CBService.h

includedServices

A list of included services.

@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.

Availability
  • Available in iOS 6.0 and later.
Declared In
CBService.h

isPrimary

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

@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 YES, the type of service is primary. If the value of this property is NO, the type of service is secondary.

Availability
  • Available in iOS 6.0 and later.
Declared In
CBService.h

UUID

The Bluetooth-specific UUID of the service.

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

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

Availability
  • Available in iOS 6.0 and later.
Declared In
CBService.h

Instance Methods

initWithType:primary:

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

- (id)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 YES, the type of service is primary. If the value is NO, the type of service is secondary.

Return Value

A newly initialized mutual service.

Availability
  • Available in iOS 6.0 and later.
Declared In
CBService.h