@@ -13,33 +13,35 @@ @implementation AppDelegate
13
13
- (BOOL )application : (UIApplication *)application
14
14
didFinishLaunchingWithOptions : (NSDictionary *)launchOptions {
15
15
[GeneratedPluginRegistrant registerWithRegistry: self ];
16
- if (@available (iOS 14 , *)) {
16
+ if (@available (iOS 14 , *)) {
17
17
// Seed the photo library with at least one image for tests to operate on.
18
18
NSString *photoAddedKey = @" PhotoAdded" ;
19
19
BOOL photoAdded = [NSUserDefaults .standardUserDefaults boolForKey: photoAddedKey];
20
20
if (!photoAdded) {
21
- NSBundle *bundle = [NSBundle bundleForClass: [self class ]];
22
- __block NSError *saveError = nil ;
23
- [PHPhotoLibrary
24
- requestAuthorizationForAccessLevel: PHAccessLevelAddOnly
25
- handler: ^(PHAuthorizationStatus status) {
26
- if ([PHPhotoLibrary.sharedPhotoLibrary
27
- performChangesAndWait: ^{
28
- NSURL *jpgImageTall =
29
- [bundle URLForResource: @" jpgImageTall"
30
- withExtension: @" jpg" ];
31
- [PHAssetChangeRequest
32
- creationRequestForAssetFromImageAtFileURL:
33
- jpgImageTall];
34
- }
35
- error: &saveError]) {
36
- [NSUserDefaults .standardUserDefaults setBool: YES forKey: photoAddedKey];
37
- } else {
38
- os_log_error (OS_LOG_DEFAULT, " %@" , saveError);
39
- }
40
- }];
41
- }
21
+ NSBundle *bundle = [NSBundle bundleForClass: [self class ]];
22
+ __block NSError *saveError = nil ;
23
+ [PHPhotoLibrary
24
+ requestAuthorizationForAccessLevel: PHAccessLevelAddOnly
25
+ handler: ^(PHAuthorizationStatus status) {
26
+ if ([PHPhotoLibrary.sharedPhotoLibrary
27
+ performChangesAndWait: ^{
28
+ NSURL *jpgImageTall =
29
+ [bundle URLForResource: @" jpgImageTall"
30
+ withExtension: @" jpg" ];
31
+ [PHAssetChangeRequest
32
+ creationRequestForAssetFromImageAtFileURL:
33
+ jpgImageTall];
34
+ }
35
+ error: &saveError]) {
36
+ [NSUserDefaults .standardUserDefaults
37
+ setBool: YES
38
+ forKey: photoAddedKey];
39
+ } else {
40
+ os_log_error (OS_LOG_DEFAULT, " %@" , saveError);
41
+ }
42
+ }];
42
43
}
44
+ }
43
45
return [super application: application didFinishLaunchingWithOptions: launchOptions];
44
46
}
45
47
0 commit comments