<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ObjectiveC",
  "identifier" : "/documentation/ObjectiveC/class_addProtocol(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Objective-C Runtime"
    ],
    "preciseIdentifier" : "c:@F@class_addProtocol"
  },
  "title" : "class_addProtocol(_:_:)"
}
-->

# class_addProtocol(_:_:)

Adds a protocol to a class.

```
func class_addProtocol(_ cls: AnyClass?, _ protocol: Protocol) -> Bool
```

## Parameters

`cls`

The class to modify.

`protocol`

The protocol to add to `cls`.

## Return Value

[`YES`](/documentation/ObjectiveC/YES) if the protocol was added successfully, otherwise [`NO`](/documentation/ObjectiveC/NO) (for example, the class already conforms to that protocol).

## Discussion

---

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)