1

How do you save a gif from the Documents or AppData folder (or otherwise known path) to the Photo Album for iOS 11?

Example of a known path: /var/mobile/Containers/Data/Application/[app uuid]/Documents/filename.gif

Older versions of this question keep referencing deprecated ALA*. How do you do this for iOS 11?

ina
  • 19,167
  • 39
  • 122
  • 201

1 Answers1

2

add frameworks foundation and photos


#import <Foundation/Foundation.h>
#import <Photos/Photos.h>

int saveGifToGallery(const char *path0){

    NSString *path = [NSString stringWithUTF8String:path0];
    NSData *data = [NSData dataWithContentsOfFile:path];
    [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
        PHAssetResourceCreationOptions *options = [[PHAssetResourceCreationOptions alloc] init];
        [[PHAssetCreationRequest creationRequestForAsset] addResourceWithType:PHAssetResourceTypePhoto data:data options:options];
    } completionHandler:^(BOOL success, NSError * _Nullable error) {
        NSLog(@":%d",success);
    }];

    return 1;

}
ina
  • 19,167
  • 39
  • 122
  • 201