---
title: "arrayWithObjects:"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/nsarray/arraywithobjects:"
---

# arrayWithObjects:

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

## Declaration

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

## Parameters

- `firstObj`: The first object for the array.

## Return Value

Return Value An array containing the objects in the argument list.

## Discussion

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: 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: NSArray *array = @[@"alpha", @"bravo", @"charlie"];

## See Also

### Creating an Array

- [array](foundation/nsarray/array.md)
- [arrayWithArray:](foundation/nsarray/arraywitharray:.md)
- [arrayWithContentsOfFile:](foundation/nsarray/arraywithcontentsoffile:.md)
- [init(object:)](foundation/nsarray/init(object:).md)
- [init(objects:count:)](foundation/nsarray/init(objects:count:)-7dct1.md)
