Reputation: 5534
I have to download images from web and save them on iPhone and then use that images for views. Main problem is: how should I save that images on iPhone ? Which method should I use ? NSUserDefaults, CoreData ?
HELP!! Thanks.
Upvotes: 0
Views: 1139
Reputation: 1242
This Question might be helpful to you. It explains both the steps you have mentioned.
iOS download and save image inside app
Upvotes: 1
Reputation: 20410
You can save the file like this:
NSData *data1 = UIImageJPEGRepresentation(image, 1.0);
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:name];
[fileManager createFileAtPath:fullPath contents:data1 attributes:nil];
if (image==nil) {
NSLog(@"Not Saved...:%@",name);
}
Upvotes: 2