Created
May 26, 2015 18:23
-
-
Save sdgandhi/e5d3e64c8893016cd765 to your computer and use it in GitHub Desktop.
save photo on iOS using Photos Framework
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
PHObjectPlaceholder *placeholderAsset; | |
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{ | |
PHAssetChangeRequest *newAssetRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:<#image#>]; | |
newAssetRequest.creationDate = <#time#>; | |
newAssetRequest.location = <#location#>; | |
placeholderAsset = newAssetRequest.placeholderForCreatedAsset; | |
PHAssetCollectionChangeRequest *addAssetRequest = [PHAssetCollectionChangeRequest changeRequestForAssetCollection:<#asset collection#>]; | |
[addAssetRequest addAssets:@[placeholderAsset]]; | |
} completionHandler:^(BOOL success, NSError *error) { | |
if (!error) { | |
NSLog(@"Asset identifier: %@", placeholderAsset.localIdentifier); | |
} | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment