目录中的文件数组

时间:2017-03-18 00:05:04

标签: macos swift3 nsfilemanager

我在操场上有以下代码,我在imageURLs上获取数组。

let imagePath = str
let url = NSURL(fileURLWithPath: imagePath)
let fileManager = FileManager.default

let properties = [URLResourceKey.localizedNameKey, URLResourceKey.creationDateKey, URLResourceKey.localizedTypeDescriptionKey]
let imageURLs = try fileManager.contentsOfDirectory(at: url as URL, includingPropertiesForKeys: properties, options:FileManager.DirectoryEnumerationOptions.skipsHiddenFiles)

然后我添加"做" "捕捉"处理项目上的错误但它停止工作。

let imagePath = Gal.urlDirectorio
let url = NSURL(fileURLWithPath: imagePath)
let fileManager = FileManager.default
let properties = [URLResourceKey.localizedNameKey, URLResourceKey.creationDateKey, URLResourceKey.localizedTypeDescriptionKey]


do { imageURLs = try fileManager.contentsOfDirectory(at: url as URL, includingPropertiesForKeys: properties, options:FileManager.DirectoryEnumerationOptions.skipsHiddenFiles)
  } catch {
       }

我按照调试过程进行操作直到"做"线。我没有错误,但它没有将网址添加到数组中。

0 个答案:

没有答案