iOS Developer Library

Developer

CBATTRequest Class Reference

Options
Deployment Target:

On This Page
Language:

CBATTRequest

The CBATTRequest class represents Attribute Protocol (ATT) read and write requests from remote central devices (represented by CBCentral objects). Remote centrals use these ATT requests to read and write characteristic values on local peripherals (represented by CBPeripheralManager objects). Local peripherals, on the other hand, use the properties of CBATTRequest objects to respond to the read and write requests appropriately, using the respondToRequest:withResult: method of the CBPeripheralManager class.

Inheritance


Conforms To


Import Statement


Swift

import CoreBluetooth

Objective-C

@import CoreBluetooth;

Availability


Available in iOS 6.0 and later.
  • central central Property

    The remote central device that originated the request. (read-only)

    Declaration

    Swift

    var central: CBCentral! { get }

    Objective-C

    @property(readonly, retain, nonatomic) CBCentral *central

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Swift

    import CoreBluetooth

    Availability

    Available in iOS 6.0 and later.

  • The characteristic whose value is to be read or written. (read-only)

    Declaration

    Swift

    var characteristic: CBCharacteristic! { get }

    Objective-C

    @property(readonly, retain, nonatomic) CBCharacteristic *characteristic

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Swift

    import CoreBluetooth

    Availability

    Available in iOS 6.0 and later.

  • value value Property

    The data being read or written.

    Declaration

    Swift

    @NSCopying var value: NSData!

    Objective-C

    @property(readwrite, copy) NSData *value

    Discussion

    The value of this property differs according to the type of request. For read requests, the property of this value is nil and should be set before responding to the remote central through the respondToRequest:withResult: method. For write requests, the value of this property is the data that is to be written to the characteristic’s value.

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Swift

    import CoreBluetooth

    Availability

    Available in iOS 6.0 and later.

    See Also

    offset

  • offset offset Property

    The zero-based index of the first byte for the read or write request. (read-only)

    Declaration

    Swift

    var offset: Int { get }

    Objective-C

    @property(readonly, nonatomic) NSUInteger offset

    Discussion

    You can use the value of this property to ensure that the ATT request is attempting to read or write within the proper bounds of the characteristic’s value. For an example of how to take a request’s offset property into account when responding to a read or write request, see Responding to Read and Write Requests from a Central.

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Swift

    import CoreBluetooth

    Availability

    Available in iOS 6.0 and later.