<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.8.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSXPCCoder",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSXPCCoder"
  },
  "title" : "NSXPCCoder"
}
-->

# NSXPCCoder

A coder that encodes and decodes objects that your app sends over an XPC connection.

```
class NSXPCCoder
```

## Overview

If you want to perform custom encoding or decoding of <doc://com.apple.documentation/documentation/Swift/Codable> objects that your app sends over an [`NSXPCConnection`](/documentation/Foundation/NSXPCConnection), use <doc://com.apple.documentation/documentation/ObjectiveC/NSObjectProtocol/isKind(of:)> to determine if the coder provided to your object is a kind of [`NSXPCCoder`](/documentation/Foundation/NSXPCCoder).

## Topics

### Inspecting the Coder

[`connection`](/documentation/Foundation/NSXPCCoder/connection)

The connection currently performing encoding or decoding.

[`userInfo`](/documentation/Foundation/NSXPCCoder/userInfo)

An optional user information object associated with the coder.

### Encoding and Decoding

[`-  encodeXPCObject:forKey:`](/documentation/Foundation/NSXPCCoder/encodeXPCObject(_:forKey:))

Encodes an object to send over an XPC connection.

[`-  decodeXPCObjectOfType:forKey:`](/documentation/Foundation/NSXPCCoder/decodeXPCObject(ofType:forKey:))

Decodes an object and validates that its type matches the type a service provides over XPC.

## Relationships

### Conforms To

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

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

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

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

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

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

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

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

### Inherits From

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

---

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)