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

# arrayWithObjects:

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

```
+ (instancetype) arrayWithObjects:(ObjectType) firstObj;
```

## Parameters

`firstObj`

The first object for the array.

## Return Value

An array containing the objects in the argument list.

## Discussion

Pass comma-separated list of trailing variadic arguments as additional objects, ending with `nil`.

The following code example creates an array containing three different types of element:

```objc
NSDate *aDate = [NSDate distantFuture];
NSValue *aValue = @(5);
NSString *aString = @"hello";
 
NSArray *array = [NSArray arrayWithObjects:aDate, aValue, aString, nil];
```

Alternatively, you can use array literal syntax in Objective-C or Swift to create an array containing given objects:

```objc
NSArray *array = @[@"alpha", @"bravo", @"charlie"];
```

---

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)