<!--
{
  "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/doesNotRecognizeSelector(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Objective-C Runtime"
    ],
    "preciseIdentifier" : "c:objc(cs)NSObject(im)doesNotRecognizeSelector:"
  },
  "title" : "doesNotRecognizeSelector(_:)"
}
-->

# doesNotRecognizeSelector(_:)

Handles messages the receiver doesn’t recognize.

```
func doesNotRecognizeSelector(_ aSelector: Selector!)
```

## Parameters

`aSelector`

A [Selector](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/Selector.html#//apple_ref/doc/uid/TP40008195-CH48) that identifies a method not implemented or recognized by the receiver.

## Discussion

The runtime system invokes this method whenever an object receives an `aSelector` message it can’t respond to or forward. This method, in turn, raises an `NSInvalidArgumentException`, and generates an error message.

Any [`doesNotRecognizeSelector(_:)`](/documentation/ObjectiveC/NSObject-swift.class/doesNotRecognizeSelector(_:)) messages are generally sent only by the runtime system. However, they can be used in program code to prevent a method from being inherited. For example, an `NSObject` subclass might renounce the [`copy()`](/documentation/ObjectiveC/NSObject-swift.class/copy()) or [`init()`](/documentation/ObjectiveC/NSObject-swift.class/init()) method by re-implementing it to include a [`doesNotRecognizeSelector(_:)`](/documentation/ObjectiveC/NSObject-swift.class/doesNotRecognizeSelector(_:)) message as follows:

```objc
- (id)copy
{
    [self doesNotRecognizeSelector:_cmd];
}
```

The `_cmd` variable is a hidden argument passed to every method that is the current selector; in this example, it identifies the selector for the `copy` method. This code prevents instances of the subclass from responding to `copy` messages or superclasses from forwarding `copy` messages—although [`responds(to:)`](/documentation/ObjectiveC/NSObjectProtocol/responds(to:)) will still report that the receiver has access to a `copy` method.

If you override this method, you must call `super` or raise an <doc://com.apple.documentation/documentation/Foundation/NSExceptionName/invalidArgumentException> exception at the end of your implementation. In other words, this method must not return normally; it must always result in an exception being thrown.

## See Also

[`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)