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

# setDelegate(_:)

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

```
func setDelegate(_ channelDelegate: Any!) -> IOReturn
```

## Parameters

`channelDelegate`

the object that will play the role of channel delegate [NOTE the l2cap channel will retain the delegate].

## 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.2.5 (Bluetooth v1.2) 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)