<!--
{
  "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/NSCopyHashTableWithZone(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:@F@NSCopyHashTableWithZone"
  },
  "title" : "NSCopyHashTableWithZone(_:_:)"
}
-->

# NSCopyHashTableWithZone(_:_:)

Performs a shallow copy of the specified hash table.

```
func NSCopyHashTableWithZone(_ table: NSHashTable<AnyObject>, _ zone: NSZone?) -> NSHashTable<AnyObject>
```

## Return Value

A pointer to a new copy of `table`, created in `zone` and containing pointers to the data elements of `table`.

## Discussion

If `zone` is `NULL`, the new table is created in the default zone.

The new table adopts the callback functions of `table` and calls the `hash` and `retain` callback functions as appropriate when inserting elements into the new table.

## See Also

[`NSCreateHashTableWithZone`](/documentation/Foundation/NSCreateHashTableWithZone(_:_:_:))

Creates a new hash table in a given zone.

[`NSCreateHashTable`](/documentation/Foundation/NSCreateHashTable(_:_:))

Creates and returns a new hash table.

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

Defines a structure that contains the function pointers used to configure behavior of `NSHashTable` with respect to elements within a hash table.



---

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)