I got completely lost here.
no idea what .map really does or why it’s needed. Then suddenly we are knee deep in closures which is a difficult topic. Then the foreach with view.addlayoutguide, I completely lost track what is happening.
Coupled with the scrollview in the next lesson which is a later part of the course which we didn’t take yet, this is not well paced.
Hi farisb!
This transforms UIImage
s into UIImageView
s:
let imageViews: [UIImageView] = images.map {image in
let imageView = UIImageView(image: image)
imageView.translatesAutoresizingMaskIntoConstraints = false
return imageView
}
And this creates a certain number of UILayoutGuide
s, based on how many images there are:
let spacerGuides = (0..<images.count - 1).map {_ in UILayoutGuide()}
You can find a refresher on map
, here: Programming in Swift · Closures and Collections
Thank you for the feedback. We’re aware that it’s too advanced to be in the learning path, where it is, and are working to improve the learning path flow!
Thank you Jessy. Will take another go at it.