From 2e5e187ec6be924a26677df0020e07dc031cf62d Mon Sep 17 00:00:00 2001 From: Alexander Maslew Date: Sat, 27 Feb 2021 04:18:06 +0200 Subject: [PATCH] Updated deprecated method --- .../PhotoTweaks/PhotoTweaksViewController.m | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/PhotoTweaks/PhotoTweaks/PhotoTweaksViewController.m b/PhotoTweaks/PhotoTweaks/PhotoTweaksViewController.m index 3ff0d53..a38c49d 100644 --- a/PhotoTweaks/PhotoTweaks/PhotoTweaksViewController.m +++ b/PhotoTweaks/PhotoTweaks/PhotoTweaksViewController.m @@ -10,6 +10,7 @@ #import "PhotoTweakView.h" #import "UIColor+Tweak.h" #import +#import @interface PhotoTweaksViewController () @@ -115,7 +116,19 @@ - (void)saveBtnTapped CGImageRelease(imageRef); if (self.autoSaveToLibray) { - UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:finishedSavingWithError:contextInfo:), nil); + __block PHObjectPlaceholder *placeholder; + + [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{ + PHAssetChangeRequest* createAssetRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:image]; + placeholder = [createAssetRequest placeholderForCreatedAsset]; + + } completionHandler:^(BOOL success, NSError *error) { + if (success) { + NSLog(@"didFinishRecordingToOutputFileAtURL - success"); + } else { + NSLog(@"%@", error); + } + }]; } [self.delegate photoTweaksController:self didFinishWithCroppedImage:image];