The Image is saved as following codes:
-(NSString *)saveImage:(UIImage *)image withName:(NSString *)name{
[self createDataPath];
NSString *filePath = [dataPath stringByAppendingPathComponent:name];
NSData *imageData = UIImageJPEGRepresentation(image, 1.0f);
[imageData writeToFile:filePath atomically:YES];
return filePath;
}
-(void)createDataPath{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
dataPath = [[[paths objectAtIndex:0]
stringByAppendingPathComponent:@"MyPhotos"]
stringByAppendingPathComponent:imageUniqueId];
/* check for existence of cache directory */
if ([[NSFileManager defaultManager] fileExistsAtPath:dataPath]) {
return;
}
NSError *error;
/* create a new cache directory */
if (![[NSFileManager defaultManager] createDirectoryAtPath:dataPath
withIntermediateDirectories:YES
attributes:nil
error:&error]) {
//URLCacheAlertWithError(error);
return;
}
}
As I know the Image saved in the NSDocumentDirectory will not be cleaned when the App updated from App Store, but the fact is these images are gone. What's going on here?