Skip to content

Instantly share code, notes, and snippets.

@geor-kasapidi
Created June 16, 2021 14:08
Show Gist options
  • Save geor-kasapidi/42f5500c24fdfebbc0c0d066637b21ca to your computer and use it in GitHub Desktop.
Save geor-kasapidi/42f5500c24fdfebbc0c0d066637b21ca to your computer and use it in GitHub Desktop.
Fetch all assets
PHPhotoLibrary.requestAuthorization(for: .readWrite) { status in
if status == .authorized {
var infos: [(CLLocation, Date)] = []
do {
let options = PHFetchOptions()
options.includeHiddenAssets = true
PHAsset.fetchAssets(with: options).enumerateObjects { asset, _, _ in
if let location = asset.location,
let date = asset.creationDate
{
infos.append((location, date))
}
}
}
print(infos)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment