Skip to content

Instantly share code, notes, and snippets.

@jllubia
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jllubia/0fc37878394d10518aac to your computer and use it in GitHub Desktop.
Save jllubia/0fc37878394d10518aac to your computer and use it in GitHub Desktop.
Deleting a picture with Photos framework causes a user prompt
__block PHObjectPlaceholder *assetPlaceholder = nil;
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest * request = [PHAssetChangeRequest creationRequestForAssetFromImage: [UIImage imageNamed:@"icon-1024-rounded"]];
assetPlaceholder = request.placeholderForCreatedAsset;
} completionHandler:^(BOOL success, NSError *error) {
NSLog(@"creation success %d - error: %@ - place: %@", success, error, assetPlaceholder);
PHFetchResult * result = [PHAsset fetchAssetsWithLocalIdentifiers: @[assetPlaceholder.localIdentifier] options: nil];
NSLog(@"Asset fetching: %@", result);
[[PHPhotoLibrary sharedPhotoLibrary] performChanges: ^{
[PHAssetChangeRequest deleteAssets: @[result.firstObject]];
} completionHandler:^(BOOL success, NSError *error) {
NSLog(@"deletion success %d - error: %@ - place: %@", success, error, assetPlaceholder);
}];
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment