Last active
August 29, 2015 14:26
-
-
Save carljparker/4d7391a8d9f58827d6fa to your computer and use it in GitHub Desktop.
iOS: Save an image file to the Documents directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
NSString *documentsPath = [paths objectAtIndex:0]; //Get the docs directory | |
NSString *filePath = [documentsPath stringByAppendingPathComponent:@"image.jpg"]; //Add the file name | |
[((Image *)obj).scaledImage writeToFile:filePath atomically:YES]; //Write the file | |
// | |
// retrieve the image | |
// | |
NSData *pngData = [NSData dataWithContentsOfFile:filePath]; | |
UIImage *image = [UIImage imageWithData:pngData]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment