0

I noticed something very strange in my app. My app records video and pictures. If I delete a video from the camera roll, it's still available to my app to play. When I delete a video the app I can go to the camera roll and it's still there.

It seems the app keeps a separate copy of the video, and the phone OS keeps another copy.

Is there some way for my app to delete both copies, or ideally only save an app specific copy that does not appear in the camera roll?

The path I use to save a movie is :

file://localhost/var/mobile/Applications/735E62F4-F5C4-49F5-A0BF-C34784F4B631/Documents/defaultFolder/1346579390.mov
4

2 回答 2

4

There are some unclear points in your question, specifically it is not clear how you are saving your videos and pictures. I will explain a bit how saving happens in general so it might help you to find your problem.

First every app has its own sandbox into which it can save its data, and no app can access the sandbox of another app. On the other hand Apple allows any app to access the Photo Library but only in 2 ways: Reading from the Photo Library, or Writing data in the Photo Library. What is not allowed in the Photo Library is deleting data. Put differently, once you saved something in the Photo Library you can not delete it from your app, the user has to do this himself manually by going to the Photo Library and deleting it from there.

Usually saving in the Photo Library is done as follows:

UIImageWriteToSavedPhotosAlbum(imageToSave, nil, nil, nil); //for image files
UISaveVideoAtPathToSavedPhotosAlbum(pathOfVideoToSave, nil, nil, nil); //for video files

So if you don't have these lines in your code the files shouldn't be saved in the Photo Library. To save data in your app sandbox you usually use:

[dataToSave writeToFile:fullPathToFile atomically:NO];

So if you only have this line in your code then you will only have the images and video saved in your app sandbox and if you delete them from your sandbox they will not be found in the Photo Library. I hope this clarifies things for you.

于 2012-09-02T11:47:32.483 回答
1

How do you create/store a taken video/picture? Normally all videos/pics are stored in a specific directories of the phone - for sure different than your app directory. So when you save it, how do you save it ? do you make a real file copy into your app folder or do you only save the link to the movie's file in the phone?

In my case I always had separate copies of pics/videos, since the app is independant of the phone's camera roll.

In the simulator you may also look directly into the app directory with Finder and see what happens when you delete a movie, if it really deletes the movie file.

于 2012-09-02T10:10:57.957 回答