November 2013
Beginner
325 pages
9h 47m
English
NSArray is another commonly used Objective-C class. An instance of NSArray holds a list of pointers to other objects.
Create a new project: a Foundation Command Line Tool called DateList. This program will create an array that holds a list of pointers to NSDate objects.
Open main.m and change main():
#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 all three
NSArray *dateList = @[now, tomorrow, yesterday]; } return ...Read now
Unlock full access