<!--
{
  "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/NSCopying",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSCopying"
  },
  "title" : "NSCopying"
}
-->

# NSCopying

A protocol that objects adopt to provide functional copies of themselves.

```
protocol NSCopying
```

## Overview

The exact meaning of “copy” can vary from class to class, but a copy must be a functionally independent object with values identical to the original at the time the copy was made. A copy produced with [`NSCopying`](/documentation/Foundation/NSCopying) is implicitly retained by the sender, who is responsible for releasing it.

[`NSCopying`](/documentation/Foundation/NSCopying) declares one method, [`copy(with:)`](/documentation/Foundation/NSCopying/copy(with:)), but copying is commonly invoked with the convenience method <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/copy()>. The <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/copy()> method is defined for all objects inheriting from <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class> and simply invokes [`copy(with:)`](/documentation/Foundation/NSCopying/copy(with:)) with the default zone.

Your options for implementing this protocol are as follows:

- Implement [`NSCopying`](/documentation/Foundation/NSCopying) using <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/alloc> and `init...` in classes that don’t inherit [`copy(with:)`](/documentation/Foundation/NSCopying/copy(with:)).
- Implement [`NSCopying`](/documentation/Foundation/NSCopying) by invoking the superclass’s [`copy(with:)`](/documentation/Foundation/NSCopying/copy(with:)) when `NSCopying` behavior is inherited. If the superclass implementation might use the [`NSCopyObject`](/documentation/Foundation/NSCopyObject) function, make explicit assignments to pointer instance variables for retained objects.
- Implement [`NSCopying`](/documentation/Foundation/NSCopying) by retaining the original instead of creating a new copy when the class and its contents are immutable.

If a subclass inherits [`NSCopying`](/documentation/Foundation/NSCopying) from its superclass and declares additional instance variables, the subclass has to override [`copy(with:)`](/documentation/Foundation/NSCopying/copy(with:)) to properly handle its own instance variables, invoking the superclass’s implementation first.

## Topics

### Copying

[`copy(with:)`](/documentation/Foundation/NSCopying/copy(with:))

Returns a new instance that’s a copy of the receiver.



---

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)