#import <Foundation/NSObject.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSString.h>
#import <Foundation/NSAutoreleasePool.h>
int main(int argc, char *argv[])
{
int i;
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init];
// create an array to contain the month names
NSArray * monthNames = [NSArray arrayWithObjects:
@"January", @"February", @"March", @"April",
@"May", @"June", @"July", @"August", @"September",
@"October", @"November", @"December", nil];
// Now list all the elements in the array
NSLog (@"Month Name");
NSLog (@"===== ====");
for (i = 0; i < 12; ++i)
NSLog(@" %2i %@", i + 1, [monthNames objectAtIndex: i] );
[pool drain];
return 0;
}
[/pre]
output
2009-02-15 13:09:42.594 Chapter15[38051:10b] Month Name
2009-02-15 13:09:42.595 Chapter15[38051:10b] ===== ====
2009-02-15 13:09:42.596 Chapter15[38051:10b] 1 January
2009-02-15 13:09:42.596 Chapter15[38051:10b] 2 February
2009-02-15 13:09:42.597 Chapter15[38051:10b] 3 March
2009-02-15 13:09:42.597 Chapter15[38051:10b] 4 April
2009-02-15 13:09:42.598 Chapter15[38051:10b] 5 May
2009-02-15 13:09:42.599 Chapter15[38051:10b] 6 June
2009-02-15 13:09:42.599 Chapter15[38051:10b] 7 July
2009-02-15 13:09:42.600 Chapter15[38051:10b] 8 August
2009-02-15 13:09:42.600 Chapter15[38051:10b] 9 September
2009-02-15 13:09:42.601 Chapter15[38051:10b] 10 October
2009-02-15 13:09:42.602 Chapter15[38051:10b] 11 November
2009-02-15 13:09:42.604 Chapter15[38051:10b] 12 December
[/pre]