iPhone/iPad OS SDK Development – Quick – Print Array in NSLog

11/02/2010

Printing an Array in NSLog can be really useful.  Just print the array as you would a string, and in NSLog you will get a nice layout of the array. I have used an example array from iPhoneSDKArticles

//Initialize the array.

listOfItems = [[NSMutableArray alloc] init];

//Add items

[listOfItems addObject:@"Iceland"];
[listOfItems addObject:@"Greenland"];
[listOfItems addObject:@"Switzerland"];
[listOfItems addObject:@"Norway"];

NSLog(@” %@”,listOfItems);

View Comments