Writes the value of a characteristic.
- iOS 5.0+
- macOS 10.7+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 4.0+
- Core Bluetooth
The value to write.
The characteristic containing the value to write.
The type of write to execute. 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(_: method of its delegate object only if you specified the write type as
CBCharacteristic. The response you receive through the
peripheral(_: delegate method indicates whether the write was successful; if the write failed, it details the cause of the failure in an error.
On the other hand, if you specify the write type as
CBCharacteristic, Core Bluetooth attempts to write the value but doesn’t guarantee success. If the write doesn’t succeed in this case, you aren’t notified and you don’t receive an error indicating the cause of the failure.
This method copies the data passed into the
data parameter, and you can dispose of it after the method returns.