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

# init(objects:count:)

Creates and returns an array that includes a given number of objects from a given C array.

```
convenience 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 new array including the first `count` objects from `objects`.

## Discussion

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

```objc
NSString *strings[3];
strings[0] = @"First";
strings[1] = @"Second";
strings[2] = @"Third";
 
NSArray *stringsArray = [NSArray arrayWithObjects:strings count:2];
// strings array contains { @"First", @"Second" }
```

## See Also

[`getObjects:range:`](/documentation/Foundation/NSArray/getObjects:range:)

Copies references to objects contained in the array that fall within the specified range to `aBuffer`.



---

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)