Objective-C
NSArray * array = @[ obj0, obj1, ... ];
[array enumerateObjectsUsingBlock: ^( id object,
NSUInteger index,
BOOL * stop )
{
// do some stuff for each "object" at "index"
}
Swift 2.0 (using "object" and "index" inside the loop)
let swiftArray: Array = [ obj0, obj1, ... ]
for ( index, object ) in swiftArray.enumerate()
{
// do some stuff for each "object" at "index"
// no explicit "stop" parameter ...
}
Swift 1.2 (using "object" and "index" inside the loop)
let swiftArray: Array = [ obj0, obj1, ... ]
for ( index, object ) in enumerate( swiftArray )
{
// do some stuff for each "object" at "index"
// no explicit "stop" parameter ...
}
Swift (using only "object" inside the loop)
for object in swiftArray
{
// do some stuff for each "object"
}
Swift (using no object information inside the loop)
for _ in swiftArray
{
// do some stuff swiftArray.count times
}