Photo replaces when save to Directory
I am using the code
NSArray *directoryNames = [NSArray
arrayWithObjects:@"hats",@"bottoms",@"right",@"left",nil];
NSArray *paths =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; // Get
documents folder
for (int i = 0; i < [directoryNames count] ; i++) {
NSString *dataPath = [documentsDirectory
stringByAppendingPathComponent:[directoryNames objectAtIndex:i]];
if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
[[NSFileManager defaultManager] createDirectoryAtPath:dataPath
withIntermediateDirectories:NO attributes:nil error:nil];
//Create folder
NSString *folderPath = [documentsDirectory
stringByAppendingPathComponent:@"hats"]; // "right" is at index 2,
per comments & code
NSString *filePath = [folderPath
stringByAppendingPathComponent:@"IMAGE_NAME_HERE.PNG"];
NSData *imageData = UIImagePNGRepresentation(captureImage.image);
[imageData writeToFile:filePath atomically:YES];
}
to save however it always replaces itself so I can't save multiple
photo's. How should I make it so that it will stop doing that without
duplicating itself?
No comments:
Post a Comment