Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get Mac system icons, as in the Finder?

Tags:

cocoa

I want to set the images in my outline view to the system icons, just like on the left in the Finder. I want to get icons like Application, Documents, Desktop, etc. How do I do this?

like image 931
jin Avatar asked Jun 08 '09 02:06

jin


2 Answers

Use NSWorkspace's iconForFile: method

NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:@"/Applications/"];

edit:

take a look at these files, are they what you're after? Your question is a little hard to understand

$ ls /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/Toolbar*FolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarAppsFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarDesktopFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarDocumentsFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarDownloadsFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarLibraryFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarMovieFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarMusicFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarPicturesFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarPublicFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarSitesFolderIcon.icns
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarUtilitiesFolderIcon.icns
like image 73
cobbal Avatar answered Nov 11 '22 04:11

cobbal


There's a method in NSWorkspace that allows you to set custom icons to folders and files:

- (BOOL)setIcon:(NSImage *)image forFile:(NSString *)fullPath
    options:(NSWorkspaceIconCreationOptions)options

Sets the icon for the file or directory at the specified path.

like image 29
diciu Avatar answered Nov 11 '22 04:11

diciu