Kyle Kyle - 1 year ago 129
Objective-C Question

Cocoa icon for file type?

If I have a file, I can get the icon by doing something such as:

NSImage *iconImage = [[NSWorkspace sharedWorkspace] iconForFile: @"myFile.png"];

But if I just wanted to get the icon for a specific file type (example the icon associated with png files, without having a "myFile.png" that already exists), i'm not sure how I can do that.

Any suggestions are appreciated!

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download