I need a little bit of help in here, I have a method that saves an UIImage to the camera roll without problems in iOS 8. The method is the following
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
[PHAssetChangeRequest creationRequestForAssetFromImage:image];
}completionHandler:^(BOOL success, NSError *error) {
if(success){
NSLog(@"worked");
}else{
NSLog(@"Error: %@", error);
}
}];
I need to adapt that code, so that the image instead of saving the UIImage to the camera roll, it saves to a custom album named "MyAlbum"
I'm using the Photos.framework
In your perform changes block, you specify the request's assetCollection
let request = PHAssetCollectionChangeRequest.creationRequestForAssetCollectionWithTitle(-YOUR ALBUM NAME-)
Create new album with name "MyAlbum" before adding a asset into the album.
Check if album already exist.
You will first need to check that the album exists with a fetch request, and then either add the image to the album or create the album and then add the image.
Objective-C
Swift 5