<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSProtocolChecker",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSProtocolChecker"
  },
  "title" : "NSProtocolChecker"
}
-->

# NSProtocolChecker

An object that restricts the messages that can be sent to another object (referred to as the checker’s delegate).

```
class NSProtocolChecker
```

## Overview

A [`NSProtocolChecker`](/documentation/Foundation/NSProtocolChecker) object can be particularly useful when an object with many methods, only a few of which ought to be remotely accessible, is made available using the distributed objects system.

A protocol checker acts as a kind of proxy; when it receives a message that is in its designated protocol, it forwards the message to its target and consequently appears to be the target object itself. However, when it receives a message not in its protocol, it raises an [`invalidArgumentException`](/documentation/Foundation/NSExceptionName/invalidArgumentException) to indicate that the message isn’t allowed, whether or not the target object implements the method.

Typically, an object that is to be distributed (yet must restrict messages) creates an [`NSProtocolChecker`](/documentation/Foundation/NSProtocolChecker) for itself and returns the checker rather than returning itself in response to any messages. The object might also register the checker as the root object of an NSConnection.

The object should be careful about vending references to `self`—the protocol checker will convert a return value of `self` to indicate the checker rather than the object for any messages forwarded by the checker, but direct references to the object (bypassing the checker) could be passed around by other objects.

## Topics

### Creating a checker

[`+  protocolCheckerWithTarget:protocol:`](/documentation/Foundation/NSProtocolChecker/protocolCheckerWithTarget:protocol:)

Allocates and initializes an `NSProtocolChecker` instance that will forward any messages in `aProtocol` to `anObject`, the protocol checker’s target.

[`-  initWithTarget:protocol:`](/documentation/Foundation/NSProtocolChecker/init(target:protocol:))

Initializes a newly allocated `NSProtocolChecker` instance that will forward any messages in `aProtocol` to `anObject`, the protocol checker’s target.

### Getting information

[`protocol`](/documentation/Foundation/NSProtocolChecker/protocol)

Returns the protocol object the receiver uses.

[`target`](/documentation/Foundation/NSProtocolChecker/target)

Returns the target of the receiver.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Sendable`](/documentation/Swift/Sendable)

### Inherits From

[`NSProxy`](/documentation/Foundation/NSProxy)

---

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)