hoe to access array elemeny in for loop in swift code example
Example 1: swift loop through array
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
}
Example 2: swift for loop index
for (index, object) in list.enumerated() {
print("Item at \(index): \(object)")
}