FileManager cannot find audio file

后端 未结 1 1965
既然无缘
既然无缘 2020-12-12 03:16

Helloo! My ultimate goal is to create a UITableViewController with recordings made in-app, using FileManager to traverse the /Documents/

相关标签:
1条回答
  • 2020-12-12 03:44

    You cannot save a sandboxed file URL or path string for later use, because the sandbox can move. You need to do what you were doing before, successfully: calculate the documents directory URL and then examine it. You should work entirely with URLs and never call absoluteString at all; it is the wrong call entirely and is letting you down here.

    In this example, I check the documents directory for any files whatever:

    let documentsDirectory = 
        FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
    let results = 
        try? FileManager.default.contentsOfDirectory(at: documentsDirectory, 
                                                     includingPropertiesForKeys: nil)
    
    0 讨论(0)
提交回复
热议问题