我有用于在Objective-C / cocoa中创建文件夹/目录的代码。
if(![fileManager fileExistsAtPath:directory isDirectory:&isDir])
if(![fileManager createDirectoryAtPath:directory attributes:nil])
NSLog(@"Error: Create folder failed %@", directory);
它工作正常,但是我收到了
creatDirectoryAtPath:attributes is deprecated
警告消息。在Cocoa / Objective-c中制作目录构建器的最新方法是什么?
解决了
BOOL isDir;
NSFileManager *fileManager= [NSFileManager defaultManager];
if(![fileManager fileExistsAtPath:directory isDirectory:&isDir])
if(![fileManager createDirectoryAtPath:directory withIntermediateDirectories:YES attributes:nil error:NULL])
NSLog(@"Error: Create folder failed %@", directory);
最佳答案
在找到的文档中大约30秒:
-[NSFileManager createDirectoryAtPath:withIntermediateDirectories:attributes:error:]
关于objective-c - 在Objective-C/cocoa中创建文件夹/目录,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5138822/