vir*_*ndh 4 filesystems objective-c nsfilemanager ios filepicker.io
现在我正在开发一个需要的iOS应用程序,NSFileManager但是当我执行该attributesOfItemAtPath:方法时,它返回null.NSData和dataWithContentsOfFile:方法也失败了.我不明白为什么会这样.我使用的文件URL看起来像这样:file://localhost/private/var/mobile/Applications/597DE145-33D7-4F92-AE95-029D5CF15291/tmp/Kv7DWqtRWH7WnN47HdDW.我怀疑它可能与URL有关,但我不确定.
rma*_*ddy 13
您需要将NSURL路径转换为与任何NSFileManager带字符串的方法一起使用的路径.通过调用pathURL上的方法来执行此操作.
NSURL *someURL = ... // some file URL
NSString *path = [someURL path]; // convert the file:// URL to a file path
NSDictionary *info = [[NSFileManager defaultManager] attributesOfItemAtPath:path];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1308 次 |
| 最近记录: |