Search code examples
cocoansimage

Is there a counterpart to NSImageNameFolder for files?


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...


Solution

  • 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>.