<!--
{
  "availability" : [
    "iOS: 1.0.0 -",
    "iPadOS: 1.0.0 -",
    "macCatalyst: 1.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 1.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ObjectiveC",
  "identifier" : "/documentation/ObjectiveC/NSObjectProtocol/responds(to:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Objective-C Runtime"
    ],
    "preciseIdentifier" : "c:objc(pl)NSObject(im)respondsToSelector:"
  },
  "title" : "responds(to:)"
}
-->

# responds(to:)

Returns a Boolean value that indicates whether the receiver implements or inherits a method that can respond to a specified message.

```
func responds(to aSelector: Selector!) -> Bool
```

## Parameters

`aSelector`

A selector that identifies a message.

## Return Value

[`YES`](/documentation/ObjectiveC/YES) if the receiver implements or inherits a method that can respond to `aSelector`, otherwise [`NO`](/documentation/ObjectiveC/NO).

## Discussion

The application is responsible for determining whether a [`NO`](/documentation/ObjectiveC/NO) response should be considered an error.

You cannot test whether an object inherits a method from its superclass by sending [`responds(to:)`](/documentation/ObjectiveC/NSObjectProtocol/responds(to:)) to the object using the `super` keyword. This method will still be testing the object as a whole, not just the superclass’s implementation. Therefore, sending [`responds(to:)`](/documentation/ObjectiveC/NSObjectProtocol/responds(to:)) to `super` is equivalent to sending it to `self`. Instead, you must invoke the `NSObject` class method [`instancesRespond(to:)`](/documentation/ObjectiveC/NSObject-swift.class/instancesRespond(to:)) directly on the object’s superclass, as illustrated in the following code fragment.

```objc
if( [MySuperclass instancesRespondToSelector:@selector(aMethod)] ) {
    // invoke the inherited method
    [super aMethod];
}
```

You cannot simply use `[[self superclass] instancesRespondToSelector:@selector(aMethod)]` since this may cause the method to fail if it is invoked by a subclass.

Note that if the receiver is able to forward `aSelector` messages to another object, it will be able to respond to the message, albeit indirectly, even though this method returns [`NO`](/documentation/ObjectiveC/NO).

## See Also

[`instancesRespond(to:)`](/documentation/ObjectiveC/NSObject-swift.class/instancesRespond(to:))

Returns a Boolean value that indicates whether instances of the receiver are capable of responding to a given selector.

[`forwardInvocation:`](/documentation/ObjectiveC/NSObject-swift.class/forwardInvocation:)

Overridden by subclasses to forward messages to other objects.



---

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)