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

Code Example 1

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

for name in names {

Code Example 2

guard let currentUser = currentUser, 
    let 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