Examples of Objective-C Loops

Matthew Campbell, April 10th, 2009

Using loops to repeat actions in programming is a common task. Objective-C does this chore in more or less the same way as other programming languages. However, if you are still unfamiliar with the Objective-C syntax you may feel a little disoriented.

So, to help out I wrote out some examples of for, for-each, do and while loops for you:

There you go – feel free to add any of your own examples on the comments below!


Click here or the box to the right to access to your online workshop now…

Each lesson comes packed with comprehensive video, source code and text. When appropriate I include hands-on exercises. Check out the list below to see what is specifically covered in each lesson:

- Lesson 1 – Overview of iPhone OS
- Lesson 2 – Introduction to Tools: XCode, Interface Builder & iPhone Simulator
- Lesson 3 – Your First App
- Lesson 4 – Super-Charge XCode

- Lesson 1 – What is Programming?
- Lesson 2 – C Programming Basics and Specifics
- Lesson 3 – Functions
- Lesson 4 – Variables and Arrays
- Lesson 5 – Program Flow
- Lesson 6 – Loops
- Lesson 7 – Complex Data with Struct
- Lesson 8 – Putting It All Together

- Lesson 1 – What is Object Oriented Programming?
- Lesson 2 – Objects
- Lesson 3 – More Strings, Lists and the For Each Loop
- Lesson 4 – Memory Management
- Lesson 5 – Designing Your Own Classes
- Lesson 6 – Extending Classes With Categories
- Lesson 7 – Protocols & Key-Value Coding

- Lesson 1 – Overview of Cocoa-Touch + Model-View-Controller
- Lesson 2 – Using Interface Builder (The View)
- Lesson 3 – Target-Action and the View in Code
- Lesson 4 – Delegation
- Lesson 5 – Super-Charging Your View With Interface Builder
- Lesson 6 – Model & App Architecture

Click here or the box to the right to access to your online workshop now