<!--
{
  "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/NSSet/init(set:)-1xovx",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSSet(im)initWithSet:"
  },
  "title" : "init(set:)"
}
-->

# init(set:)

Initializes a newly allocated set and adds to it objects from another given set.

```
convenience init(set: Set<AnyHashable>)
```

## Parameters

`set`

A set containing objects to add to the receiving set. Each object is retained as it is added.

## Return Value

An initialized objects set containing the objects from `set`. The returned set might be different than the original receiver.

## See Also

[`-  initWithObjects:`](/documentation/Foundation/NSSet/initWithObjects:)

Initializes a newly allocated set with members taken from the specified list of objects.

[`+  setWithSet:`](/documentation/Foundation/NSSet/setWithSet:)

Creates and returns a set containing the objects from another set.



---

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)