November 2013
Beginner
325 pages
9h 47m
English
Arrays are ordered lists, and you access an item in an array by its index.
Arrays are zero-based: the first item is stored at index 0, the second item is stored at index 1, and so on.
You can access an individual item in the array using the name of the array followed by the index of the item in square brackets. Add the following code to your program to access and print two items in the array:
#import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool { // Create three NSDate objects NSDate *now = [NSDate date]; NSDate *tomorrow = [now dateByAddingTimeInterval:24.0 * 60.0 * 60.0]; NSDate *yesterday = [now dateByAddingTimeInterval:-24.0 * 60.0 * 60.0]; // Create an array containing ...Read now
Unlock full access