title: Swift 3 - Fetch All Photos From Library
body: <p>I've tried to fetch photos from the library. It works, but I just got 3 photos from 9 photos from the library. Here's my code:</p>
  
  <pre><code>let options = PHFetchOptions()
      let userAlbums = PHAssetCollection.fetchAssetCollections(with: PHAssetCollectionType.album, subtype: PHAssetCollectionSubtype.any, options: options)
  
      let userPhotos = PHAsset.fetchKeyAssets(in: userAlbums.firstObject!, options: nil)
      let imageManager = PHCachingImageManager()
  
      userPhotos?.enumerateObjects({ (object: AnyObject!, count: Int, stop: UnsafeMutablePointer) in
          if object is PHAsset {
              let obj:PHAsset = object as! PHAsset
  
              let fetchOptions = PHFetchOptions()
              fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]
              fetchOptions.predicate = NSPredicate(format: "mediaType = %d", PHAssetMediaType.image.rawValue)
  
              let options = PHImageRequestOptions()
              options.deliveryMode = .fastFormat
              options.isSynchronous = true
  
              imageManager.requestImage(for: obj, targetSize: CGSize(width: obj.pixelWidth, height: obj.pixelHeight), contentMode: .aspectFill, options: options, resultHandler: { img, info in
  
                  self.images.append(img!)
              })
          }
      })
  </code></pre>
  
  <p>When I tried <code>images.count</code>, it said 3. Can anyone help me to find my mistake and get all photos? Big thanks!</p>