Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找一种方法来显示已安装驱动器以及特定文件夹的图标。我阅读了 NSWorkspace 的所有文档并找到了这段代码,但我无法使用它来获取已安装卷的图标。
let icon = NSWorkspace.shared().icon(forFile: path.absoluteString)
那么有没有什么方法可以获取Macintosh HD 驱动器的图标呢?
这只是获得正确路径的问题。磁盘卷安装在/Volumes:
/Volumes
let icon = NSWorkspace.shared().icon(forFile: "/Volumes/Macintosh HD")