For and ForEach Loops in Objective-C

Matthew Campbell, May 13th, 2009

iStock_000008790379XSmall.jpgLoops are the gears of programming: they make your code take action.

The two loops I use most often is the for loop (to do a predefined number of steps) and what is usually called a foreach loop (to move though a list of objects).

//This loop simply repeats an action
//a set amount of times:
for (int i=0; i<=3; i++)
NSLog([NSString stringWithFormat:@"i=%i", i]);

 

Learn How To Make Your Own iPhone and iPad iOS apps!

If you are completely new to iPhone programming and want to start to developing iPhone apps this ebook will give you everything you need to get started today.

You Get the 5 Essential Things You Need to Make iPhone Apps

This ebook is much different than the other books out there: it really is a *system* that includes ONLY what you need to know to make iPhone applications. Not only that, but you will get some real insight on how to make a product and how to set up your code in the best way the first time.

Plus, you will get plenty of bonuses including exclusive source code projects. For more information, head on over to the website for the ebook: