title: iOS 8 Load Images Fast From PHAsset
body: <p>I have an app that lets people combine up to 4 pictures. However when I let them choose from their photos (up to 4) it can be very slow even when I set image quality to FastFormat. It will take 4 seconds (about 1 second per photo). On highest quality, 4 images takes 6 seconds.</p>
  
  <p>Can you suggest anyway I get get the images out faster?</p>
  
  <p>Here is the block where I process images.</p>
  
  <pre><code>func processImages()
      {
          _selectediImages = Array()
          _cacheImageComplete = 0
          for asset in _selectedAssets
          {
              var options:PHImageRequestOptions = PHImageRequestOptions()
              options.synchronous = true
              options.deliveryMode = PHImageRequestOptionsDeliveryMode.FastFormat
              PHImageManager.defaultManager().requestImageForAsset(asset, targetSize:CGSizeMake(CGFloat(asset.pixelWidth), CGFloat(asset.pixelHeight)), contentMode: .AspectFit, options: options)
                  {
                      result, info in
                      var minRatio:CGFloat = 1
                      //Reduce file size so take 1/3 the screen w&amp;h
                      if(CGFloat(asset.pixelWidth) &gt; UIScreen.mainScreen().bounds.width/2 || CGFloat(asset.pixelHeight) &gt; UIScreen.mainScreen().bounds.height/2)
                      {
                          minRatio = min((UIScreen.mainScreen().bounds.width/2)/(CGFloat(asset.pixelWidth)), ((UIScreen.mainScreen().bounds.height/2)/CGFloat(asset.pixelHeight)))
                      }
                      var size:CGSize = CGSizeMake((CGFloat(asset.pixelWidth)*minRatio),(CGFloat(asset.pixelHeight)*minRatio))
                      UIGraphicsBeginImageContextWithOptions(size, false, 0.0)
                      result.drawInRect(CGRectMake(0, 0, size.width, size.height))
                      var final = UIGraphicsGetImageFromCurrentImageContext()
                      var image = iImage(uiimage: final)
                      self._selectediImages.append(image)
                      self._cacheImageComplete!++
                      println(self._cacheImageComplete)
                      if(self._cacheImageComplete == self._selectionCount)
                      {
                          self._processingImages = false
                          self.selectionCallback(self._selectediImages)
                      }
              }
  
          }
      }
  </code></pre>