Last active
August 29, 2015 13:57
-
-
Save arod2634/9360274 to your computer and use it in GitHub Desktop.
Looping though an NSMutableArray
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSMutableArray *myParty = [[NSMutableArray alloc] init]; | |
[myParty addObject:@"Name: Alex's Awesome Party"]; | |
[myParty addObject:@"Address: 123 Awesome Street"]; | |
[myParty addObject:@"Date: May 17"]; | |
// Manually output the value in each index | |
NSLog(@"%@",[myParty objectAtIndex:0]); | |
NSLog(@"%@",[myParty objectAtIndex:1]); | |
NSLog(@"%@",[myParty objectAtIndex:2]); | |
// Loop though array in with a traditional for loop | |
for (int i = 0; i < [myParty count]; i++) { | |
NSLog(@"%@", myParty[i]); | |
} | |
// Loop though array using fast enumeration | |
for (id detail in myParty) { | |
NSLog(@"%@", detail); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment