i have one application in that i download all data in local .
in this data also image coming i want to store this ima开发者_高级运维ge in local .
can i store this image in local? if yes ! how ?
from online image path (url) coming.
Save the image in UIImage and then save it to local like this;
NSData *imageData = UIImagePNGRepresentation(image);
NSString *imageName = [NSString stringWithFormat:@"image.png"];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fullPathToFile = [documentsDirectory stringByAppendingPathComponent:imageName];
[imageData writeToFile:fullPathToFile atomically:YES];
精彩评论