Mau*_*itz 1 nsfilemanager swift4
我正在查看NSFileManager.hSwift 4中的dox,自从我上次使用它以来它似乎发生了变化(为了更好!).
在我的案例图片中,我想知道是否contentsOfDirectoryAtURL:includingPropertiesForKeys,url或enumeratorAtURL:includingPropertiesForKeys提供一种枚举特定类型文件的方法?
我看过很多Swift 2的答案,他们都建议循环和检查名称,我想确定他们没有"修复"这个,我只是对API感到困惑?
刚filter回来URLs的pathExtension
do {
let documentsURL = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
let docs = try FileManager.default.contentsOfDirectory(at: documentsURL, includingPropertiesForKeys: [], options: [.skipsHiddenFiles, .skipsSubdirectoryDescendants])
let images = docs.filter{ $0.pathExtension == "xxx" }
print(images)
} catch {
print(error)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2200 次 |
| 最近记录: |