Tag Archives: NSArray

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:

How to convert an NSArray into an NSMutableArray

There’s a handy function called arrayWithArray that we can use:

Likewise we can convert a mutable array into a standard one: