Search code examples
iosswiftphassetphphotolibrary

Delete a single photo from a burst from the camera roll in Swift


So I have code that will delete images from the camera roll. It works fine, and can delete single images from a burst, however one of the images, if deleted, will delete the entire batch and I can't figure out how to stop that. It usually seems to be the last image in the burst group. And in my request options, I turn on includeAllBurstAssets.

func deletePhotos(assetsToDelete: [PHAsset]){
   PHPhotoLibrary.sharedPhotoLibrary().performChanges({
        PHAssetChangeRequest.deleteAssets(assetsToDelete)
            return
        }, completionHandler: { success, error in

            guard let error = error else {
             return
            }

            print(error)
         }
    })
}

Solution

  • I can confirm this behavior. I guess the API is designed to delete the entire batch, if one burst photo is deleted. Please note, that the Apple Photos app also has no method to delete single burst photos. It would make sense to make that behavior customizable and I would suggest you fill a bug report /enhancement request.