I'm trying to create a method to download image from internet.
It download a bunch of image by NSData
, it's work but I have to save it in the device. The problem is that it download perfectly and I can access to the image but if I delete the app or close the running bg app I can't access to the image, it's like it disappear. So it only work if I download and access to the image immediately.. it isn't permanent.
Here is my code:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString *newDirectory = [NSString stringWithFormat:@"%@/toyotacotizador", [paths objectAtIndex:0]];
NSString* path = [newDirectory stringByAppendingPathComponent:
[NSString stringWithFormat:@"image-appdownloader-%d-%d.png", tablePointer,tagDictionary] ];
NSData* data = UIImagePNGRepresentation(image);
[data writeToFile:path atomically:YES];
[self.dbManager loadDataFromDB:[NSString stringWithFormat:@"UPDATE %@ SET image='%@' WHERE %@ = '%@';", [dataImage getTableName], path, [dataImage getIdTableColumn], [dataImage getIdQuery]]];
The route of the image is correct but I can't access to the image if I close the entire app process or delete the app.
It's like the image is only visible when I download it.