我想在文档目录中创建文件夹并希望将图像保存在该文件夹中。我已经尝试过,但文件夹和图像存储在文档目录中..但我想将图像存储在文件夹中。我的代码工作正常,但图像没有保存在文件夹中..
NSError *error;
NSString *aDocumentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *dataPath = [aDocumentsDirectory stringByAppendingPathComponent:@"Folder"];
[[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&error];
NSInteger anIndex = 0;
for (UIImage *anImage in _chosenImages)
{
NSString *anImageName = [NSString stringWithFormat:@"%d.png", anIndex++];
NSString *anImagePath = [NSString stringWithFormat:@"%@/%@", aDocumentsDirectory, anImageName];
NSLog(@"the path is=%@",anImagePath);
NSData *anImageData = UIImagePNGRepresentation(anImage);
[anImageData writeToFile:anImagePath atomically:YES];
}