Suppose you have collection of type e.g;
NSMutableArray, etc and you would like to iterate over all the elements one by one. One way to iterate over the collection would be to use
do-while loop structure. But to use them, you have to know how many elements are in the collection to make sure you stay in the bounds of the collection object. Fast Enumeration help you to iterate the collection without worrying about this.
General Syntax of Enumeration
The above syntax has 4 parts
- For loop structure.
- Declaring the type of objects collection have (
in, this will proceeded by the collection object.
collectionObject, object holding the content.
1 2 3 4 5
1 2 3 4