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

# NSHashInsertKnownAbsent(_:_:)

Adds an element to the specified hash table.

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

## Discussion

Inserts `pointer`, which must not be `NULL`, into `table`. Unlike `NSHashInsert`, this function raises `NSInvalidArgumentException` if `table` already includes an element that matches `pointer`.

## See Also

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

Removes an element from the specified hash table.

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

Adds an element to 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)