Delete a movie clip resource using a photo structure

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?

+5
source share
1 answer

Let me make sure that I understand the question:

1) You use the photo framework to delete an asset using PHAssetChangeRequest.deleteAssets (assetToDelete)

2) you will go to the Photos application and view the Deleted photos, but you don’t see the image / object that you just deleted in the trash in the Photos application.

If this is what you are experiencing, it is due to the fact that you deleted an object that is not in the users’ clip but is PHAsst from the photo stream from another device. When you delete these assets, they are not sent to the trash and are deleted differently than a regular photo. I would recommend switching to the application of photos and deleting the same asset - if it is an object of a photo stream, you will see that it never ends up in the basket.

If this is not the problem you are facing, try providing more details.

0
source

Source: https://habr.com/ru/post/1214184/


All Articles