---
title: "Literal Syntax for NSArray, NSDictionary & NSNumber"
url: https://deallocatedobjects.com/posts/new-objective-c-literal-syntax-for-nsarray-nsdictionary-nsnumber
author: Jake Marsh
published: 2012-03-13
updated: 2014-11-19
link: http://joris.kluivers.nl/blog/2012/03/13/new-objectivec-literal-syntax/
topics: ["iOS Development"]
description: "I can’t tell you how long I’ve been waiting for this. As Joris points out, it appears that Apple has committed the necessary changes to the LLVM project to allow LLVM to fully support the latest Objective-C language features."
---

# Literal Syntax for NSArray, NSDictionary & NSNumber

By Jake Marsh, March 13, 2012. HTML: https://deallocatedobjects.com/posts/new-objective-c-literal-syntax-for-nsarray-nsdictionary-nsnumber

This is a link post about http://joris.kluivers.nl/blog/2012/03/13/new-objectivec-literal-syntax/

I can't tell you how long I've been waiting for this.

As [Joris points out](http://joris.kluivers.nl/blog/2012/03/13/new-objectivec-literal-syntax/), it appears that Apple has [committed the necessary changes](http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/?view=log&pathrev=152137) to the LLVM project to allow LLVM to fully support the latest Objective-C language features.

> Apple committed a new patch to the llvm project adding support for new Objective-C literal syntax for `NSArray`, `NSDictionary` and `NSNumber`. These have previously been documented in the Mountain Lion Xcode release notes but that was still under NDA. Now that these features have been committed to llvm I guess we’re allowed to speak about it.

...and since LLVM isn't under NDA like most of the "developer preview" stuff, this means we can all finally discuss this stuff on our blogs!

Here's a (small) taste of the great new syntax:

### NSNumber

``` objc
NSNumber *someNumber = @31;  // [NSNumber numberWithInt:31] 
```

### NSArray

``` objc
//NSArray *doctors = [NSArray arrayWithObjects:@"Matt Smith", @"David Tennant", @"Tom Baker", nil];
NSArray *doctors = @[@"Matt Smith", @"David Tennant", @"Tom Baker"];
```

### NSDictionary

``` objc
NSDictionary *tweet = @{
  @"text": @"Hi! I'm a tweet!",
  @"user": @"jakemarsh",
  @"timestamp": @1331664532
};
```
