Writes the value of a characteristic.
- iOS 5.0+
- macOS 10.7+
- tvOS 9.0+
- watchOS 4.0+
- Core Bluetooth
The value to be written.
The characteristic whose value is to be written.
The type of write to be executed. For a list of the possible types of writes to a characteristic’s value, see
When you call this method to write the value of a characteristic, the peripheral calls the peripheral:didWriteValueForCharacteristic:error: method of its delegate object only if you specified the write type as
CBCharacteristic. The response you receive through the peripheral:didWriteValueForCharacteristic:error: delegate method indicates whether the write was successful; if the write failed, it details the cause of the failure in an error. If you specify the write type as
CBCharacteristic, the write is best-effort and not guaranteed. If the write does not succeed in this case, you are not notified nor do you receive an error indicating the cause of the failure. The data passed into the
data parameter is copied, and you can dispose of it after the method returns.
Characteristics may allow only certain type of writes to be performed on their value. To determine which types of writes are permitted to a characteristic’s value, you access the relevant properties of the CBCharacteristicProperties enumeration, which are detailed in