<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ObjectiveC",
  "identifier" : "/documentation/ObjectiveC/NSObject-swift.class/conforms(to:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Objective-C Runtime"
    ],
    "preciseIdentifier" : "c:objc(cs)NSObject(cm)conformsToProtocol:"
  },
  "title" : "conforms(to:)"
}
-->

# conforms(to:)

Returns a Boolean value that indicates whether the target conforms to a given protocol.

```
class func conforms(to protocol: Protocol) -> Bool
```

## Parameters

`protocol`

A protocol.

## Return Value

[`YES`](/documentation/ObjectiveC/YES) if the target conforms to `protocol`, otherwise [`NO`](/documentation/ObjectiveC/NO).

## Discussion

A class “conforms to” a protocol if it adopts the protocol or inherits from another class that adopts it. Classes adopt protocols by listing them within angle brackets after the interface declaration. For example, here `MyClass` adopts the (fictitious) `AffiliationRequests` and `Normalization` protocols:

```objc
@interface MyClass : NSObject <AffiliationRequests, Normalization>
```

A class also conforms to any protocols included in the protocols it adopts or inherits. Protocols incorporate other protocols in the same way classes adopt them. For example, here the `AffiliationRequests` protocol incorporates the `Joining` protocol:

```objc
@protocol AffiliationRequests <Joining>
```

If a class adopts a protocol that incorporates another protocol, it must also implement all the methods in the incorporated protocol or inherit those methods from a class that adopts it.

This method determines conformance solely on the basis of the formal declarations in header files, as illustrated above. It doesn’t check to see whether the methods declared in the protocol are actually implemented—that’s the programmer’s responsibility.

To specify the protocol required as this method’s argument, use the `@protocol()` directive:

```objc
BOOL canJoin = [MyClass conformsToProtocol:@protocol(Joining)];
```

### Performance Considerations

Calling this method in performance sensitive code can cause unwanted performance problems. [`conforms(to:)`](/documentation/ObjectiveC/NSObject-swift.class/conforms(to:)) requires taking the Objective-C runtime lock and traversing the target’s class hierarchy to check for protocol conformance, which can take significant time.

Consider the following alternatives in your code:

- Use [`responds(to:)`](/documentation/ObjectiveC/NSObjectProtocol/responds(to:)) to check for methods in the protocol instead, especially if you only need to check some of the protocol’s methods.
- If you do need to use [`conforms(to:)`](/documentation/ObjectiveC/NSObjectProtocol/conforms(to:)), cache the result whenever possible, rather than calling this method repeatedly.

---

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)