5// Created by Alex Chan on 08/06/2023.
11/// Looks up an album by name.
13/// This assumes that album names are globally unique.
14func getAlbum(withName name: String) -> PHAssetCollection {
17 .fetchAssetCollections(with: .album, subtype: .albumRegular, options: nil)
19 var thisAssetCollection: PHAssetCollection? = nil
21 collections.enumerateObjects({ (album, index, stop) in
22 let assetCollection = album
24 if assetCollection.localizedTitle == Optional(name) {
25 thisAssetCollection = assetCollection
29 if let assetCollection = thisAssetCollection {
30 return assetCollection
32 fatalError("Unable to find album with name: \(name).\n")