Created
December 14, 2011 05:16
-
-
Save stith/1475372 to your computer and use it in GitHub Desktop.
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
NSString *filename = [NSString stringWithFormat:@"%0.0f.png", [[NSDate date] timeIntervalSince1970]]; | |
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; | |
MSLogTo(@"info", @"documentsPath = %@",documentsPath); | |
NSURL *newUrl = [NSURL fileURLWithPath:documentsPath isDirectory:YES]; | |
NSString *saveTo = [[newUrl absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; | |
MSLogTo(@"info", @"Saving image to %@",saveTo); | |
NSError *error; | |
if (![UIImagePNGRepresentation(image) writeToFile:saveTo options:NSDataWritingAtomic error:&error]) { | |
MSLogTo(@"errors",@"Couldn't save image to documents: %@ <%@>",error,[error localizedDescription]); | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment