Created
June 16, 2021 14:08
-
-
Save geor-kasapidi/42f5500c24fdfebbc0c0d066637b21ca to your computer and use it in GitHub Desktop.
Fetch all assets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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