O'Reilly logo

Programming in Objective-C, Sixth Edition by Stephen G. Kochan

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

Structures

The Objective-C language provides another tool besides arrays for grouping elements. You also can use structures, which form the basis for the discussions in this section.

Suppose you wanted to store a date—say, 7/18/14—inside a program, perhaps to be used for the heading of some program output or even for computational purposes. A natural method for storing the date is to simply assign the month to an integer variable called month, the day to an integer variable day, and the year to an integer variable year. So, the statements

int month = 7, day = 18, year = 2014;

would work just fine. This is a totally acceptable approach. But what if your program also needed to store several dates? It would be much ...

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