How to loop through every element in an NSArray

We can use something called Fast Enumeration for this, using a modified for loop:

You don’t have to use dynamic typing if you know the types of objects you’re using. In our example this would work just as well:

Fast Enumeration also works with NSDictionaries of course:

Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or draw on tablet devices. He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.

Add your voice!