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

# init(set:copyItems:)

Initializes a new ordered set with the contents of a set, optionally copying the objects in the set.

## Declaration

```swift
convenience init(set: Set<AnyHashable>, copyItems flag: Bool)
```

## Parameters

- `set`: The 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 the objects in the set.

## See Also

### Initializing an Ordered Set

- [init(array:)](foundation/nsorderedset/init(array:).md)
- [init(array:copyItems:)](foundation/nsorderedset/init(array:copyitems:).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()](foundation/nsorderedset/init().md)
