O'Reilly logo

Objective-C Quick Syntax Reference by Matthew Campbell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 8

image

Arrays

NSArray

NSArray is a class used to organize objects in lists. NSArray can maintain an index of objects, search for objects, and enumerate through the list. Enumeration is the process of moving through a list one item at a time and performing an action on each item in the list.

To create an array, you include a comma-separate list of objects enclosed in square brackets and started with the @ symbol.

NSArray *numbers = @[@-2, @-1, @0, @1, @2];NSArray *letters = @[@"A", @"B", @"C", @"D", @"E", @"F"];

The NSArray object numbers has a list of NSNumber objects, while letters has a list of strings. Any object can be put into an NSArray ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required