<!--
{
  "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/NSOrderedSet/init(objects:count:)-3ny0m",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSOrderedSet(cm)orderedSetWithObjects:count:"
  },
  "title" : "init(objects:count:)"
}
-->

# init(objects:count:)

Creates and returns a set containing a specified number of objects from a given C array of objects.

```
convenience init(objects: UnsafePointer<AnyObject>, count cnt: Int)
```

## Parameters

`objects`

A C array of objects to add to the new ordered set.

    If the same object appears more than once in objects, it is added only once to the returned ordered set. Each object receives a retain message as it is added to the set.

`cnt`

The number of objects from objects to add to the new set.

## Return Value

A new ordered set containing cnt objects from the list of objects specified by `objects`.

## See Also

[`+  orderedSetWithSet:`](/documentation/Foundation/NSOrderedSet/orderedSetWithSet:)

Creates and returns an ordered set with the contents of a set.

[`+  orderedSetWithOrderedSet:`](/documentation/Foundation/NSOrderedSet/orderedSetWithOrderedSet:)

Creates and returns an ordered set containing the objects from another ordered set.

[`-  initWithOrderedSet:copyItems:`](/documentation/Foundation/NSOrderedSet/init(orderedSet:copyItems:))

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

[`+  orderedSetWithObjects:`](/documentation/Foundation/NSOrderedSet/orderedSetWithObjects:)

Creates and returns a ordered set containing the objects in a given argument list.

[`+  orderedSetWithObject:`](/documentation/Foundation/NSOrderedSet/orderedSetWithObject:)

Creates and returns a ordered set that contains a single given object.

[`-  initWithOrderedSet:`](/documentation/Foundation/NSOrderedSet/init(orderedSet:))

Initializes a new ordered set with the contents of a 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)