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

# NSHashInsert(_:_:)

Adds an element to the specified hash table.

```
func NSHashInsert(_ table: NSHashTable<AnyObject>, _ pointer: UnsafeRawPointer?)
```

## Discussion

Inserts `pointer`, which must not be `NULL`, into `table`. If `pointer` matches an item already in the table, the previous pointer is released using the `release` callback function that was specified when the table was created.

## See Also

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

Adds an element to the specified hash table.

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

Removes an element from the specified hash table.

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

Adds an element to the specified hash table only if the table does not already contain the element.



---

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)