<!--
{
  "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

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

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

## Relationships

### Conforming Types

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[`EnergyKit`](/documentation/Foundation/UnitEnergy/EnergyKit)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

---

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)