3

Possible Duplicate:
Apple LLVM 4.0 new features on Xcode 4.4 (Literals)

I am using Xcode 4.5 and would like to use the new syntax to adding objects to arrays, in my old code I have:

NSArray *array = [[NSArray alloc] initWithObjects: rabbit, chicken, owl, nil];

What is the correct way to use the new syntax that is being introduced, for example:

@[rabbit, chicken, owl]

TIA.

Community
  • 1
  • 1

2 Answers2

5

Your code is correct, i.e.:

NSArray *array = @[ rabbit, chicken, owl ];
Tutankhamen
  • 3,532
  • 1
  • 30
  • 38
4

What you have is correct. Here is some more documentation on the subject.

trojanfoe
  • 120,358
  • 21
  • 212
  • 242