作者热门文章
- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我正在尝试创建一个目录
NSError*error=nil;
NSString* BIDirectory=[[NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask,YES) objectAtIndex:0] stringByAppendingPathComponent:@"BI"];
BOOL isDir,flag=YES;
//if the directory doesn't exist create it.
if(!([[NSFileManager defaultManager] fileExistsAtPath:BIDirectory isDirectory:&isDir]&& isDir))
flag=[[NSFileManager defaultManager] createDirectoryAtURL:[NSURL URLWithString:BIDirectory] withIntermediateDirectories:YES attributes:nil error:&error];
我得到了以下错误
enter code hereError Domain=NSCocoaErrorDomain Code=518 "The operation couldn’t be completed. (Cocoa error 518.)" UserInfo=0x197190 {NSURL=/var/mobile/Applications/55793654-6CDB-4B07-8FBF-553DC37D583D/Library/Caches/BI}
也许 url 是错误的?
最佳答案
代替
[NSURL URLWithString:BIDirectory]
请使用
[NSURL fileURLWithPath:BIDirectory]
在本地文件上使用 URLWithString:BIDirectory 是错误的
关于ios - NSFileManager 创建目录错误 518 NSFileWriteUnsupportedSchemeError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10744316/
我正在尝试创建一个目录 NSError*error=nil; NSString* BIDirectory=[[NSSearchPathForDirectoriesInDomains(NSCachesD
我是一名优秀的程序员,十分优秀!