3

NSImage comes with a number of system images. One of them being NSImageNameFolder for a generic folder icon.

What about a generic image for a single file or document? There does not seem to be such a thing as NSImageNameDocument...

Mark
  • 6,647
  • 1
  • 45
  • 88

1 Answers1

2

You should be able to use the following:

NSImage *fileImage = [[NSWorkspace sharedWorkspace]
             iconForFileType:NSFileTypeForHFSTypeCode(kGenericDocumentIcon)];

If necessary, you may need to import <CoreServices/CoreServices.h>.

NSGod
  • 22,699
  • 3
  • 58
  • 66
  • 1
    Nice! Swift variant: `NSWorkspace.shared.icon(forFileType: NSFileTypeForHFSTypeCode(OSType(kGenericDocumentIcon)))` – Johan Kool Sep 24 '18 at 07:40