Cocoa icon for file type?

Underneath -[NSWorkspace iconForFile:] in the documentation is -[NSWorkspace iconForFileType:]. Have you tried that?


You can first determine file type (UTI) and then pass it on to get icon:

NSString *fileName = @"lemur.jpg"; // generic path to some file
CFStringRef fileExtension = (__bridge CFStringRef)[fileName pathExtension];
CFStringRef fileUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, NULL);

NSImage *image = [[NSWorkspace sharedWorkspace]iconForFileType:(__bridge NSString *)fileUTI];