在 iPhone 中创建一个目录
这有什么问题吗?
#define AUDIO_NOTES_FOLDER [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/myApp/Pictures"]
NSFileManager *NSFm= [NSFileManager defaultManager];
BOOL isDir=YES;
if(![NSFm fileExistsAtPath:FILEPATH isDirectory:&isDir])
if(![NSFm createDirectoryAtPath:FILEPATH attributes:nil])
NSLog(@"Error: Create folder failed");
What's wrong with that?
#define AUDIO_NOTES_FOLDER [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/myApp/Pictures"]
NSFileManager *NSFm= [NSFileManager defaultManager];
BOOL isDir=YES;
if(![NSFm fileExistsAtPath:FILEPATH isDirectory:&isDir])
if(![NSFm createDirectoryAtPath:FILEPATH attributes:nil])
NSLog(@"Error: Create folder failed");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
createDirectoryAtPath:attributes:
已弃用,您应该使用:createDirectoryAtPath:attributes:
is deprecated, instead you should use:FILEPATH 标记未定义 - 您在文件开头
#define AUDIO_NOTES_FOLDER
,然后在代码中使用FILEPATH
。另请注意, NSHomeDirectory() 不一定是查找文档目录的推荐方法 - 相反,您可能需要:
The FILEPATH token is undefined - you
#define AUDIO_NOTES_FOLDER
at the beginning of your file, then useFILEPATH
instead in your code.Also note that NSHomeDirectory() isn't necessarily the recommended way of finding the Documents directory anymore - instead you probably want: