Title here
Summary here
Our first example demonstrates how to work with arrays in Objective-C. Arrays are ordered collections of elements of a specific type.
When you run this program, you’ll see output similar to:
Note that arrays in Objective-C are actually objects (instances of NSArray
or NSMutableArray
), and they can only contain objects. For primitive types like int
, we wrap them in NSNumber
objects.
Also, Objective-C arrays are zero-indexed, meaning the first element is at index 0.
Objective-C provides two main types of arrays:
NSArray
: An immutable array that can’t be changed after creation.NSMutableArray
: A mutable array that can be modified after creation.In this example, we’ve used both types to demonstrate different array operations.