Photos and videos are not saving in my custom photo album (TestAlbum). Instead, it is saving in the Camera Roll. Can you kindly help me to identify the issue and help me to correct the code.
PHPhotoLibrary.shared().performChanges({
let albumName = "TestAlbum"
let assetCollection: PHAssetCollection!
let fetchOptions = PHFetchOptions()
PHAssetCollectionChangeRequest.creationRequestForAssetCollection(withTitle: albumName)
fetchOptions.predicate = NSPredicate(format: "title = %@", albumName)
let collection = PHAssetCollection.fetchAssetCollections(with: .album, subtype: .any, options: fetchOptions)
if let _: AnyObject = collection.firstObject {
collection.firstObject
}
let options = PHAssetResourceCreationOptions()
options.shouldMoveFile = true
let creationRequest = PHAssetCreationRequest.forAsset()
creationRequest.addResource(with: .video, fileURL: outputFileURL, options: options)
}, completionHandler: { success, error in
if !success {
print("Could not save movie to photo library: \(String(describing: error))")
}
cleanUp()
})