I released an app that the user can edit some pictures and save it on the own app (I mean: it is not saved on camera roll). Sometime after, I released the version 2.0 of the app and the users complained the update process deleted their saved pictures.
It follows part of my code where the pictures are saved:
NSData *dataFromPNG = UIImagePNGRepresentation(image);
NSString *mainPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingString:@"/SavedData"];
NSString *directory = [mainPath stringByAppendingPathComponent:[NSString stringWithFormat:@"image(%d).png", imageIndex]];
[dataFromPNG writeToFile:directory atomically:YES];
Where is my mistake?
How you are calculating your imageIndex ? I think, problem is there. If they have saved 10 images with last version, then are you calculating last index with new version?
I think, you are overwriting images, so it seems that update is deleting. It was a guess with code you provided. Try this and if its not the solution, provide your code to calculate imageIndex.