我有一个选择器,可以将我的图像保存在NSDocumentDirectory
此处:
for (int i = 0; i < image.count; i++) {
NSLog(@"%@", [image objectAtIndex:i]);
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask ,YES );
NSString *documentsDirec = [paths objectAtIndex:0];
NSString *savedPath = [documentsDirec stringByAppendingPathComponent:[NSString stringWithFormat:@"myImages%d.png", i]];
ALAssetRepresentation *rep = [[image objectAtIndex: i] defaultRepresentation];
UIImage *image = [UIImage imageWithCGImage:[rep fullResolutionImage]];
NSData *imageData = UIImagePNGRepresentation(image);
[imageData writeToFile:savedPath atomically:YES];
NSLog(@"saving at:%@",savedPath);
}
如何确定或实施检查现有图像/图像名称是否已经存在。然后,如果图像存在,即使它仍然在选择器中被选中,它也不会添加相同的图像/图像名称。