Skip to content

Instantly share code, notes, and snippets.

@phnessu4
Created May 26, 2015 04:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phnessu4/4cac9224c94b2bdd01d1 to your computer and use it in GitHub Desktop.
Save phnessu4/4cac9224c94b2bdd01d1 to your computer and use it in GitHub Desktop.
save file to path
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);
NSString *ourDocumentPath =[documentPaths objectAtIndex:0];
NSString * filepath = [ourDocumentPath stringByAppendingString:[NSString stringWithFormat:@"image%lu.png",(unsigned long)index]];
// [fileManager createDirectoryAtPath:filepath withIntermediateDirectories:YES attributes:nil error:nil];
[fileManager createFileAtPath:filepath
contents:UIImagePNGRepresentation(image)
attributes:nil];
NSLog(@"-------file %@",filepath);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment