How are you getting the icon otherwise? It's not quite otherwise. Normally I just use NSWorkspace.shared.icon(forFile:). But folders require special logic. If the folder name has a . prefix, then I call NSWorkspace.shared.icon(for: .folder). I'm not sure why. Probably should have commented that. But if the folder doesn't have a . prefix, I use the standard NSWorkspace.shared.icon(forFile:). Then, I check to see if I need to do more. I the URL has the com.apple.icon.folder#S extended attribute, I try QLThumbnailGenerator. QLThumbnailGenerator is async anyway, so it really always requires the two-step process.
Topic:
UI Frameworks
SubTopic:
AppKit
Tags: