Skip to content

Instantly share code, notes, and snippets.

@sdgandhi
Created May 26, 2015 18:23
Show Gist options
  • Save sdgandhi/e5d3e64c8893016cd765 to your computer and use it in GitHub Desktop.
Save sdgandhi/e5d3e64c8893016cd765 to your computer and use it in GitHub Desktop.
save photo on iOS using Photos Framework
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