How to get only images in the camera roll using Photos Framework

William Falcon picture William Falcon · Sep 8, 2014 · Viewed 28.7k times · Source

The following code loads images that are also located on iCloud or the streams images. How can we limit the search to only images in the camera roll?

var assets = PHAsset.fetchAssetsWithMediaType(PHAssetMediaType.Image, options: nil)

Answer

StatusReport picture StatusReport · Jan 21, 2015

After adding the Camera Roll and Photo Stream albums, Apple added the following PHAssetCollectionSubtype types in iOS 8.1:

  1. PHAssetCollectionSubtypeAlbumMyPhotoStream (together with PHAssetCollectionTypeAlbum) - fetches the Photo Stream album.

  2. PHAssetCollectionSubtypeSmartAlbumUserLibrary (together with PHAssetCollectionTypeSmartAlbum) - fetches the Camera Roll album.

Haven't tested if this is backward-compatible with iOS 8.0.x though.