Multidimensional Arrays

The types of arrays you’ve seen thus far are all linear arrays; that is, they all deal with a single dimension. The language enables you to define arrays of any dimension. This section takes a look at two-dimensional arrays.

One of the most natural applications for a two-dimensional array arises in the case of a matrix. Consider the 4 × 5 matrix shown here:

10         5           –3        17         82

9           0           0          8          –7

32         20         1          0           14

0           0           8          7           6

In mathematics, an element of a matrix commonly is referred to by using a double subscript. If the preceding matrix were called M, the notation Mi,j would refer to the element ...

Get Programming in Objective-C, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.