/ Published in: Objective C
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//Loops //For loop    for (int y = 0; y < 3; y ) {    NSLog(@\"y = %i\", y); } //Do loop x = 0; do{    NSLog(@\"x = %i\", x);    x ; } while(x <= 4); //While loop x = 0; while (x <= 4 ) {    NSLog(@\"x = %i\", x);    x ; } //For each loop //Create an array and add elements to it NSMutableArray *anArray = [[NSMutableArray alloc] init]; [anArray addObject:@\"Element 1\"]; [anArray addObject:@\"Element 2\"]; [anArray addObject:@\"Element 3\"]; //Use a for each loop to iterate through the array for (NSString *s in anArray) {    NSLog(s); } //Release the array [anArray release];
URL: http://howtomakeiphoneapps.com/2009/04/examples-of-objective-c-loops-2/