title: How to load Sequence of images from a video using "generateCGImagesAsynchronously"?
body: <p>I want to generate images to a Scroll view (just like when a video starts playing in default ios player).</p>
  
  <pre><code>let imageView = UIImageView()
  let asset :AVAsset = AVURLAsset.init(url: url as URL)
  let assetImgGenerate : AVAssetImageGenerator = AVAssetImageGenerator(asset: asset)
  assetImgGenerate.appliesPreferredTrackTransform = true
  assetImgGenerate.requestedTimeToleranceAfter = kCMTimeZero;
  assetImgGenerate.requestedTimeToleranceBefore = kCMTimeZero;
  
  var img = UIImage()
  
  assetImgGenerate.appliesPreferredTrackTransform = true
  let thumbTime: CMTime = asset.duration
  let times = thumbTime as NSValue
  
  assetImgGenerate.generateCGImagesAsynchronously(forTimes: [times], completionHandler: {( requestedTime, image, actualTime,result, error) -&gt; Void in
    img = UIImage(cgImage: image!)
    imageView.image = img
  })
  
  scrollView.backgroundColor = UIColor.black
  scrollView.contentSize = CGSize(width: CGFloat(imageView.frame.width), height: 0)
  scrollView.addSubview(imageView)}
  </code></pre>
  
  <p>this doesn't give any output. How can I generate Images as a sequence to be displayed inside a scroll view?</p>
  
  <p>What am I doing wrong here?</p>