I am writing a test application to find out if it is possible to delete the "photo library" resource in iOS 8 using the "Photos" framework. Although I suspect this is not possible, I believe the documentation is unclear and there are reports on this site that seem to indicate that this is possible. See here for example.
In my test application, I select an asset from the library:
var picker = UIImagePickerController() picker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary picker.mediaTypes = [kUTTypeMovie]
In the delegate callback, I get the NSURL of the asset and put it in an array:
let thePicked = info[UIImagePickerControllerMediaURL] as NSURL! var videosToDelete: [NSURL] = [theURL]
And here is the part in which I'm least sure where I get PhotoLibrary, and I make a change request to delete the asset:
PHPhotoLibrary.sharedPhotoLibrary().performChanges( { let assetToDelete = PHAsset.fetchAssetsWithALAssetURLs(videosToDelete, options: nil) PHAssetChangeRequest.deleteAssets(assetToDelete) }, completionHandler: { success, error in NSLog("Finished deleting asset. %@", (success ? "Success" : error)) })
The completion handler returns successfully, but the asset is never deleted. Am I doing something wrong? Or am I trying to make something inherently unacceptable, and I am not getting the right feedback from it?
source share