<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "IOBluetooth",
  "identifier" : "/documentation/IOBluetooth/IOBluetoothL2CAPChannel/setDelegate(_:withConfiguration:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "IOBluetooth"
    ],
    "preciseIdentifier" : "c:objc(cs)IOBluetoothL2CAPChannel(im)setDelegate:withConfiguration:"
  },
  "title" : "setDelegate(_:withConfiguration:)"
}
-->

# setDelegate(_:withConfiguration:)

Allows an object to register itself as client of the L2CAP channel.

```
func setDelegate(_ channelDelegate: Any!, withConfiguration channelConfiguration: [AnyHashable : Any]!) -> IOReturn
```

## Parameters

`channelDelegate`

the object that will play the role of channel delegate.

`channelConfiguration`

the dictionary that describes the initial configuration for the channel.

## Return Value

Returns kIOReturnSuccess if the delegate is successfully registered.

## Discussion

A channel delegate is the object the L2CAP channel uses as target for data and events. The developer will implement only the the methods he/she is interested in. A list of the possible methods is at the end of this file in the definition of the informal protocol IOBluetoothL2CAPChannelDelegate. A newly opened L2CAP channel will not complete its configuration process until the client that opened it registers a connectionHandler. This prevents that case where incoming data is received before the client is ready.

NOTE: This method is only available in macOS 10.5 (Bluetooth v2.0) or later.

---

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)