Save image to Documents folder


/ Published in: Objective C
Save to your folder(s)



Copy this code and paste it in your HTML
  1. NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]
  2. stringByAppendingPathComponent:@"images"];
  3.  
  4. // save the file
  5. NSString *imagePath = [path stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png",
  6. [imageName stringByReplacingOccurrencesOfString:@" " withString:@"_"]]];
  7. if ([[NSFileManager defaultManager] fileExistsAtPath:imagePath]) {
  8. // delete if exist
  9. [[NSFileManager defaultManager] removeItemAtPath:imagePath error:nil];
  10. }
  11.  
  12. NSData *imageDate = [NSData dataWithData:UIImagePNGRepresentation(image)];
  13.  
  14. [imageDate writeToFile: imagePath atomically: YES];

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.