Solved

Delete images from camera roll

Posted on 2010-09-23
1
2,730 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
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.

708 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

17 Experts available now in Live!

Get 1:1 Help Now