title: how to get all images from phone in ios
body: <p>I want to get all images from the phone.for create multiple selections in photos library.I am using below code to get all images from the phone. it's working perfectly but when on the phone have 1000 images its take more time to get all images and show on view.How to reduce the time of getting all images from the phone.</p>
  
  <pre><code> // get all images from photos
      func getAllImagesFromPhotos() -&gt; [Photos]?
      {
  
          let imgManager = PHImageManager.default()
          let requestOptions = PHImageRequestOptions()
          requestOptions.isSynchronous = true
          let fetchOptions = PHFetchOptions()
          fetchOptions.sortDescriptors = [NSSortDescriptor(key:"creationDate", ascending: true)]
  
          let fetchResult = PHAsset.fetchAssets(with: PHAssetMediaType.image, options: fetchOptions)
  
          var allImages = [Photos]()
  
          for index in 0..&lt;fetchResult.count
          {
              let asset = fetchResult.object(at: index) as PHAsset
              imgManager.requestImage(for: asset, targetSize: CGSize(width:200,height:200), contentMode: .aspectFill, options: requestOptions, resultHandler: { (uiimage, info) in
                  if let image = uiimage
                  {
                      allImages.append(Photos(image: image, selected: false))
                  }
              })
          }
  
          return allImages
      }
  </code></pre>