Save image to Documents folder
Copy this code and paste it in your HTML
NSString *path
= [[NSHomeDirectory
() stringByAppendingPathComponent
:@"Documents"] stringByAppendingPathComponent:@"images"];
// save the file
NSString *imagePath
= [path stringByAppendingPathComponent
:[NSString stringWithFormat
:@"%@.png",
[imageName stringByReplacingOccurrencesOfString:@" " withString:@"_"]]];
if ([[NSFileManager defaultManager
] fileExistsAtPath
:imagePath
]) { // delete if exist
[[NSFileManager defaultManager
] removeItemAtPath
:imagePath error
:nil];
}
NSData *imageDate
= [NSData dataWithData
:UIImagePNGRepresentation
(image
)];
[imageDate writeToFile: imagePath atomically: YES];
Report this snippet
Comments
Subscribe to comments