cocoa-touch - NSDirectoryEnumerator : are the returned path relative?

标签 cocoa-touch cocoa relative-path nsfilemanager absolute-path

根据docNSDirectoryEnumerator 返回的路径应该相对于枚举的文件夹:

An NSDirectoryEnumerator object enumerates the contents of a directory, returning the pathnames of all files and directories contained within that directory. These pathnames are relative to the directory.

但是,当我这么做的时候

NSDirectoryEnumerator *dirEnum = [myFileManager enumeratorAtURL:URLFolder
                                     includingPropertiesForKeys:nil
                                                        options:NSDirectoryEnumerationSkipsHiddenFiles
                                                   errorHandler:^BOOL(NSURL *url, NSError *error) {
                                                               return YES ;}];

我得到的是绝对路径!

这是正常现象还是已知问题?

最佳答案

函数enumeratorAtURL:includingPropertiesForKeys:options:errorHandler:实际上应该返回绝对路径(请参阅链接中的讨论)。如果需要相对路径值,可以使用 enumeratorAtPath: .

关于cocoa-touch - NSDirectoryEnumerator : are the returned path relative?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20095666/

相关文章:

javascript - PHP 包含包含相对路径的 html 文件

ios - 去除 uisearchbar 中 uitextfield 的边框

用于显示目录列表的 Cocoa Control/View

c++ - 使用 fopen 打开文件,在 Windows 上给定绝对路径

cocoa - 有没有办法让 NSAnimation "Begin from current state"就像在 iPhone 上一样?

cocoa - 对状态栏项的 NSMenu 进行逆向工程

bash - 如何将 chdir 分配给 .bat 中的变量?

ios - 使用 iOS 平移手势突出显示网格中的按钮

ios - Cocoa Touch 获取用户全名

objective-c - dispatch_async 慢于 PerformSelectorInBackground :?