Search code examples
objective-ccocoaiconsnsimage

How do I get the desktop icon used in Finder?


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?


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