I have built an app to take safety questionnaires. The app allows to add a photo to individual questions. I use UIImagePickerController
for this. Since iOS 11 I noticed that, both in the simulator as well as iPad, selecting an image from the photo library will automatically save the selected image in the tmp folder of the app with a 'temp' name (e.g. 57576A97-21D4-465F-91B6-11215F8B5F97.jpeg). This happens even before didFinishPickingMediaWithIn
is performed.
This is my code for setting the UIImagePickerController
:
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .photoLibrary;
imagePicker.allowsEditing = false
self.present(imagePicker, animated: true, completion: nil)
This image is not deleted during the usage of the app. In case the user adds lots of photo's, this would mean that all these photo's will be stored in the tmp directory, which in the end might lead to a crash.
For the moment I have made a work around which searches for the 'temp' files and deletes them each time.
I have checked with the iOS 10.1 simulator, but no copies of the selected image are made in the temp directory (with the same code). When testing on the iPad, using the camera does not lead to 'temp' copies of selected images
My question is: is saving a temp file by the UIImagePicker
standard behavior in iOS 11, or can it be avoided?