<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSCoder/encodeBycopyObject(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSCoder(im)encodeBycopyObject:"
  },
  "title" : "encodeBycopyObject(_:)"
}
-->

# encodeBycopyObject(_:)

An encoding method for subclasses to override such that it creates a copy, rather than a proxy, when decoded.

```
func encodeBycopyObject(_ anObject: Any?)
```

## Discussion

`NSCoder`’s implementation simply invokes [`encode(_:)`](/documentation/Foundation/NSCoder/encode(_:)-9648d).

This method must be matched by a corresponding [`decodeObject()`](/documentation/Foundation/NSCoder/decodeObject()) message.

---

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)