Solved

Delete images from camera roll

Posted on 2010-09-23
1
2,738 Views
Last Modified: 2013-11-25
How can you delete phones from the camera roll in xcode?
0
Comment
Question by:BTMExpert
1 Comment
 
LVL 33

Accepted Solution

by:
pgnatyuk earned 500 total points
ID: 33751037
I do not know how to delete the photo's programmatically.
(But everybody knows how to save.)
iPhone  app has access to the files in its sandbox.
Can you save the images in the application document folder? So then you can delete it using the standard file manager?

NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,  YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:name];

NSError *error = nil;
if( [fileManager fileExistsAtPath:fullPath] )
        [fileManager removeItemAtPath:fullPath error:&error] );

Here is a blog post with save and remove code:
Using NSFileManager to save an image to or load/remove an image from documents directory
http://www.friendlydeveloper.com/2010/02/using-nsfilemanager-to-save-an-image-to-or-loadremove-an-image-from-documents-directory-coding/

More about file operations on iPhone:
iPhone File System: Creating, Renaming and Deleting Files
http://iphonedevelopertips.com/data-file-management/iphone-file-system-creating-renaming-and-deleting-files.html

Maybe, you can find something in the open source iphone browsers?
http://code.google.com/p/iphonebrowser/downloads/list
0

Featured Post

Want to promote your upcoming event?

Are you going to an event? Are you going to be exhibiting at a tradeshow? Talking at a conference? Using a promotional banner in your email signature ensures that your organization’s most important contacts stay in the know and can potentially spread the word about the event.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How do I test for current date? 9 95
Picking random number 8 175
Having a file "symlink" to a memory location (Windows) 6 169
C hashtable library 3 83
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now