[code] @autoreleasepool
{
NSMutableArray groceries = [NSMutableArray array]; / created an empty NSMutableArray */
[groceries addObject:@"bread"]; /* added NSString object to Index[0] */
[groceries addObject:@"milk"]; /* added NSString object to Index[1] */
[groceries addObject:@"cheese"]; /* added NSString object to Index[2] */
NSLog(@"There are %lu items:", [groceries count]); /* count states the number of objects in the array */
for (NSString *g in groceries) /* fast enumeration for loop prints out the groceries list */
{
NSLog(@"%@", g);
}
}[/code]Output:
[quote]2014-11-16 15:58:54.925 Groceries[22032:303] There are 3 items:
2014-11-16 15:58:54.926 Groceries[22032:303] bread
2014-11-16 15:58:54.926 Groceries[22032:303] milk
2014-11-16 15:58:54.927 Groceries[22032:303] cheese[/quote]
[color=#000040]JR[/color]