Created
December 23, 2017 10:55
-
-
Save yosun/89f256b66141ec914e2b54c66c91c798 to your computer and use it in GitHub Desktop.
saveGifToGallery - call from unity using extern or see SaveToAlbum.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note - requires manually adding Photos and Foundation frameworks in xcode