<!--
{
  "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/NSArray/init(objects:count:)-5odxv",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSArray(im)initWithObjects:count:"
  },
  "title" : "init(objects:count:)"
}
-->

# init(objects:count:)

Initializes a newly allocated array to include a given number of objects from a given C array.

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

## Parameters

`objects`

A C array of objects.

`cnt`

The number of values from the `objects` C array to include in the new array. This number will be the count of the new array—it must not be negative or greater than the number of elements in `objects`.

## Return Value

A newly allocated array including the first `count` objects from `objects`. The returned object might be different than the original receiver.

## Discussion

Elements are added to the new array in the same order they appear in `objects`, up to but not including index `count`.

After an immutable array has been initialized in this way, it can’t be modified.

This method is a designated initializer.

## See Also

[`+  arrayWithObjects:`](/documentation/Foundation/NSArray/arrayWithObjects:)

Creates and returns an array containing the objects in the argument list.

[`-  initWithObjects:`](/documentation/Foundation/NSArray/initWithObjects:)

Initializes a newly allocated array by placing in it the objects in the argument list.



---

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)