Skip to content

Instantly share code, notes, and snippets.

@phnessu4
Created May 26, 2015 04:47
Show Gist options
  • Select an option

  • Save phnessu4/4cac9224c94b2bdd01d1 to your computer and use it in GitHub Desktop.

Select an option

Save phnessu4/4cac9224c94b2bdd01d1 to your computer and use it in GitHub Desktop.

Revisions

  1. phnessu4 created this gist May 26, 2015.
    10 changes: 10 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    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);