我有以下代码
let webPath = URL(string: "http://peterlinnik.com/Plex%20Music/The%20Beatles%20-%20Discography/Abbey%20Road/")
do {
// Get the directory contents urls (including subfolders urls)
let webFiles = try FileManager.default.contentsOfDirectory(at: webPath!, includingPropertiesForKeys: nil, options: [])
print(webFiles)
} catch let error as NSError {
print(error.localizedDescription)
}
我正在尝试用这个目录的内容填充一个 TableView ,目前我只是想让它打印那里的内容,但收到以下错误,
The folder “Abbey Road” doesn’t exist.
我做错了什么,这甚至可以做到吗?
最佳答案
Web URL 不是文件 URL。
您的 URL 指向一个 HTML 页面 - 这与文件系统文件夹无关。
您看到的通过 HTML 显示的服务器文件夹不会作为实际文件夹直接显示给您。
关于swift - 用在线文件目录填充 TableView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41021853/