<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreBluetooth",
  "identifier" : "/documentation/CoreBluetooth/CBPeripheral/writeValue(_:for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Bluetooth"
    ],
    "preciseIdentifier" : "c:objc(cs)CBPeripheral(im)writeValue:forDescriptor:"
  },
  "title" : "writeValue(_:for:)"
}
-->

# writeValue(_:for:)

Writes the value of a characteristic descriptor.

```
func writeValue(_ data: Data, for descriptor: CBDescriptor)
```

## Parameters

`data`

The value to write.

`descriptor`

The descriptor containing the value to write.

## Discussion

When you call this method to write the value of a characteristic descriptor, the peripheral calls the [`peripheral(_:didWriteValueFor:error:)`](/documentation/CoreBluetooth/CBPeripheralDelegate/peripheral(_:didWriteValueFor:error:)-1ybl3) method of its delegate object.

This method copies the `data` passed into the data parameter, and you can dispose of it after the method returns.

You can’t use this method to write the value of a client configuration descriptor (represented by the [`CBUUIDClientCharacteristicConfigurationString`](/documentation/CoreBluetooth/CBUUIDClientCharacteristicConfigurationString) constant), which describes the configuration of notification or indications for a characteristic’s value. If you want to manage notifications or indications for a characteristic’s value, you must use the [`setNotifyValue(_:for:)`](/documentation/CoreBluetooth/CBPeripheral/setNotifyValue(_:for:)) method instead.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)