Arrays in Objective-C @techytube
Arrays in Objective-C  @techytube
Uploaded September 2012 | Updated September 2026, 2 weeks ago
Subscribe to our channel here for notifications on new video trainings. For more videos on technology, visit our website at http://www.techytube.com.
By pavel@techytube, for more from this author visit:
techytube.com/author/pavel

As Objective-C is a super-set of C, we can use the C-style of declaring and using arrays.
The syntax for declaring an using an array in this way is:

int firstArray[5] = { 1, 2, 3, 4, 5 };
NSLog(@"The first element is: %d", firstArray[0]);

The Objective-C of declaring, initializing and using arrays is as follows:

NSArray *secondArray = [NSArray arrayWithObjects:
[NSNumber numberWithInt:1],
[NSNumber numberWithInt:2],
[NSNumber numberWithInt:3],
[NSNumber numberWithInt:4],
[NSNumber numberWithInt:5],
nil];
NSLog(@"The first element is: %d", [secondArray[0] intValue]);

Arrays in Objective-C are zero-index based, that means the first element will have the index zero, but not one.
The last element in an array should always be "nil".
In the example above we've made an immutable array. There is also the mutable version, which is represented by the NSMutableArray class.

Arrays in Objective-C may contain elements of different types, that means we can store a NSNumber object, and a NSString object in the same array, for example.
Arrays in Objective-CInstalling MySQL On a Developer MachineFailover Clustering in Windows Server 2016Introduction to File Management in Objective-CWorking with UIAlertView class in iOSWindows 7 vs Windows 8 Setup Speed ComparisonRestoring database backups Differential and Transaction Log Backups, Part 4Windows 8 - Surviving the upgrade. the keyboard shortcuts to knowWorking with UIAlertViewDelegate protocol methods in iOS.NET 3.5/WPF Creating A Splash ScreenWindows 8 Development - Application DataYum (Yellow Dog Updater Modified) Part 4 of 4
techytube |

Arrays in Objective-C

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER