我想创建一个子文件夹来存储由相机和相机拍摄的图像。还需要将图像存储到数据库中并从数据库中检索图像。
因此,请向我提供有关如何在iPhone和iPhone中创建文件夹的帮助。如何将图像存储到数据库和检索它们
答案 0 :(得分:7)
在文档文件夹中创建目录
- (void)createDirectoryInDocumentsFolderWithName:(NSString *)dirName {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *yourDirPath = [documentsDirectory stringByAppendingPathComponent:dirName];
NSFileManager *fileManager = [NSFileManager defaultManager];
BOOL isDir = YES;
BOOL isDirExists = [fileManager fileExistsAtPath:yourDirPath isDirectory:&isDir];
if (!isDirExists) [fileManager createDirectoryAtPath:yourDirPath withIntermediateDirectories:YES attributes:nil error:nil];
}