Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing images to the iphone

Is it possible to save images captured by the camera on the iphone to a custom directory or somewhere on the iphone rather than saving to the camera roll?

I would like to save images to the device and then have access to the at a later stage, rather than reading from the camera roll using ALAssets.

Is this possible?

like image 419
some_id Avatar asked Mar 10 '11 19:03

some_id


People also ask

Where can I store my photos to free up space on iPhone?

Move your photos and videos to cloud storage On your iPhone, open Settings. Tap [your name] > iCloud > Photos. Toggle the switch to turn on iCloud Photos. Tap Optimize iPhone Storage.

Is it safe to store photos on iPhone?

Everything stored in iCloud, including iCloud photos, is securely encrypted in transit and stored with encryption keys. Encryption keys are stored on Apple's servers. Without these encryption keys, files can not be decrypted. Apple also uses “end-to-end” encryption for data.

What's the best way to store pictures from your phone?

For a physical backup, go with a secure external drive If you want to store your photos physically, a secure external drive is a better choice. These devices tend to have higher storage capacity and faster speeds, plus they're harder to lose. They're also cheaper now than they were years ago.


1 Answers

Yes you can save them to your apps' documents folder. Here is an example:

// Create path
NSString  *imagePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/ImageName.png"];

// Write image to PNG
[UIImagePNGRepresentation(image) writeToFile:imagePath atomically:YES];

To retrieve it:

UIImage *image = [UIImage imageWithContentsOfFile:imagePath];

To list all files in a directory:

NSFileManager *manager = [NSFileManager defaultManager];
NSArray *fileList = [manager directoryContentsAtPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]];
for (NSString *s in fileList){
    NSLog(s);
}
like image 103
theChrisKent Avatar answered Sep 21 '22 22:09

theChrisKent