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

# init(array:)

Returns a counted set object initialized with the contents of a given array.

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

## Parameters

`array`

An array of objects to add to the new set.

## Return Value

An initialized counted set object with the contents of `array`. The returned object might be different than the original receiver.

## See Also

  [Collections Programming Topics](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Collections/Collections.html#//apple_ref/doc/uid/10000034i)

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

Creates and returns a set containing a uniqued collection of the objects contained in a given array.

[`-  initWithArray:`](/documentation/Foundation/NSSet/init(array:))

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



---

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)