Skip to content

Instantly share code, notes, and snippets.

@benvium
Created January 13, 2013 09:02
Show Gist options
  • Select an option

  • Save benvium/4523079 to your computer and use it in GitHub Desktop.

Select an option

Save benvium/4523079 to your computer and use it in GitHub Desktop.
Write UIImage to documents directory
// UIImage called 'image'
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"foo.png"];
NSData *imageData = UIImagePNGRepresentation(image);
[imageData writeToURL:[NSURL fileURLWithPath:filePath] atomically:YES];
NSLog(@"written to %@", filePath);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment