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

# init(array:copyItems:)

Initializes a newly allocated set with the objects that are contained in a given array, optionally copying the items.

## Declaration

```swift
convenience init(array set: [Any], copyItems flag: Bool)
```

## Parameters

- `set`: 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 ordered set.
- `flag`: If doc://com.apple.documentation/documentation/Swift/true the objects are copied to the ordered set; otherwise doc://com.apple.documentation/documentation/Swift/false.

## Return Value

Return Value An initialized ordered set containing a uniqued collection of the objects contained in the array.

## See Also

### Initializing an Ordered Set

- [init(array:)](foundation/nsorderedset/init(array:).md)
- [init(array:range:copyItems:)](foundation/nsorderedset/init(array:range:copyitems:).md)
- [init(object:)](foundation/nsorderedset/init(object:).md)
- [init(objects:count:)](foundation/nsorderedset/init(objects:count:)-2ai32.md)
- [init(orderedSet:)](foundation/nsorderedset/init(orderedset:).md)
- [init(orderedSet:copyItems:)](foundation/nsorderedset/init(orderedset:copyitems:).md)
- [init(orderedSet:range:copyItems:)](foundation/nsorderedset/init(orderedset:range:copyitems:).md)
- [init(set:)](foundation/nsorderedset/init(set:).md)
- [init(set:copyItems:)](foundation/nsorderedset/init(set:copyitems:).md)
- [init()](foundation/nsorderedset/init().md)
