Check out example codes for "loop through array swift". It will help you in understanding the concepts better.

Code Example 1

let names = ["a", "b", "c"]

for name in names {
    print(name)
}

Code Example 2

guard let currentUser = currentUser, 
    let photos = currentUser.photos as? [ModelAttachment] else 
{
    // break or return
}
// now 'photos' is available outside the guard
for object in photos {
    let url = object.url
}

Learn ReactJs, React Native from akashmittal.com