---
title: "init(array:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsset/init(array:)"
---

# init(array:)

Initializes a newly allocated set with the objects that are contained in a given array.

## Declaration

```swift
convenience init(array: [Any])
```

## Parameters

- `array`: An array of objects to add to the new set. If the same object appears more than once in array, it is represented only once in the returned set. Each object receives a doc://com.apple.documentation/documentation/ObjectiveC/NSObject-c.protocol/retain message as it is added to the set.

## Return Value

Return Value An initialized set with the contents of array. The returned set might be different than the original receiver.

## See Also

### Initializing a Set

- [init(objects:count:)](foundation/nsset/init(objects:count:)-7kift.md)
- [init(set:)](foundation/nsset/init(set:)-1xovx.md)
- [init(set:copyItems:)](foundation/nsset/init(set:copyitems:).md)
- [init()](foundation/nsset/init().md)
