Skip to content

Instantly share code, notes, and snippets.

@sourleangchhean168
Created May 12, 2017 06:51
Show Gist options
  • Save sourleangchhean168/306cfeb6bfc3332dc2da693f76d632e4 to your computer and use it in GitHub Desktop.
Save sourleangchhean168/306cfeb6bfc3332dc2da693f76d632e4 to your computer and use it in GitHub Desktop.
Get screenshot (album) count in swift
let albumsPhoto:PHFetchResult<PHAssetCollection> = PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .albumRegular, options: nil)
albumsPhoto.enumerateObjects({(collection, index, object) in
if collection.localizedTitle == "Screenshots"{
let photoInAlbum = PHAsset.fetchAssets(in: collection, options: nil)
print(photoInAlbum.count) //Screenshots albums count
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment