-
StackOverflow 文件
-
Swift Language 教程
-
快取磁碟空間
-
讀
let url = "https://path-to-media"
guard let documentsUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first,
let searchQuery = url.absoluteString.components(separatedBy: "/").last else {
return nil
}
do {
let directoryContents = try FileManager.default.contentsOfDirectory(at: documentsUrl, includingPropertiesForKeys: nil, options: [])
let cachedFiles = directoryContents.filter { $0.absoluteString.contains(searchQuery) }
// do something with the files found by the url
} catch {
// Could not find any files
}