Question

In Objective-c/Cocoa, how do I get the icon that Finder uses for the desktop (it looks like the black/pink nebula desktop image with a menu bar and dock).

I tried this:

NSImage *icon = [[NSWorkspace sharedWorkspace] 
                 iconForFileType: NSFileTypeForHFSTypeCode(kDesktopIcon)];

But all I get is a blue folder with a ghosted desktop-looking box on it. Is there another constant that provides this icon, or another method altogether for getting the icon?

Was it helpful?

Solution

The icon you're looking for is located at: /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarDesktopFolderIcon.icns

I wasn't able to find a constant for it, but you could load the image in with imageWithContentsOfFile:.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top