【发布时间】:2021-10-02 14:10:15
【问题描述】:
我想知道我是否使用 FileManager 将一堆文件添加到 Documents 目录中,然后在稍后检索它们,它们是否已经按“添加日期”顺序排列?即,最旧的将在数组中排在第一位,而最新的将在数组中排在最后。
我问这个是因为在模拟器中如果我执行fm.createFile(atPath: ".../Documents/hello1.txt", contents: someData, attributes: nil) 然后执行fm.createFile(atPath: ".../Documents/hello2.txt", contents: someData, attributes: nil) 并检索它们,它们会按顺序显示(hello1 首先然后是 hello2)。我想知道这种行为是否会始终保持一致。如果是,那么我可以通过 fm.contentsOfDirectory(atPath: .../Documents).first! 获取目录中最旧的文件。
如果此行为在实际 iOS 设备上保持一致,请告诉我。
提前致谢。
【问题讨论】:
标签: ios swift nsfilemanager