Last active
August 29, 2015 14:26
-
-
Save jllubia/0fc37878394d10518aac to your computer and use it in GitHub Desktop.
Deleting a picture with Photos framework causes a user prompt
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
__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