---
title: "dictionaryWithObjectsAndKeys:"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/nsdictionary/dictionarywithobjectsandkeys:"
---

# dictionaryWithObjectsAndKeys:

Creates a dictionary containing entries constructed from the specified set of values and keys.

## Declaration

```occ
+ (instancetype) dictionaryWithObjectsAndKeys:(id) firstObject;
```

## Parameters

- `firstObject`: The first value to add to the new dictionary.

## Discussion

Discussion After passing firstObj, pass a null-terminated list of alternating values and keys as variadic arguments. If any key is nil, an invalidArgumentException is raised. This method is similar to dictionaryWithObjects:forKeys:, differing only in the way key-value pairs are specified. For example: NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:     @"value1", @"key1", @"value2", @"key2", nil];

## See Also

### Creating a Dictionary from Objects and Keys

- [dictionaryWithObjects:forKeys:](foundation/nsdictionary/dictionarywithobjects:forkeys:.md)
- [dictionaryWithObjects:forKeys:count:](foundation/nsdictionary/dictionarywithobjects:forkeys:count:.md)
- [init(objects:forKeys:)](foundation/nsdictionary/init(objects:forkeys:).md)
- [init(objects:forKeys:count:)](foundation/nsdictionary/init(objects:forkeys:count:).md)
- [initWithObjectsAndKeys:](foundation/nsdictionary/initwithobjectsandkeys:.md)
- [init(object:forKey:)](foundation/nsdictionary/init(object:forkey:).md)
