views:

512

answers:

2

Am currently working on a project, and though I can add sidebar items by adding to the com.apple.sidebarlists.plist file then restarting Finder, I can't seem to know how to make the folder icons show up using its assigned custom icon.

Can anyone point me to a link or a solution that would make me do this? Thanks a bunch in advance!

+2  A: 

There's no supported way to do this using pure Cocoa. Use the LSSharedFileList API, instead. It's the supported way to manage the sidebar lists, and you can provide a custom icon (as an IconRef from Icon Services) when you insert an item.

Peter Hosey
A: 

I was too stubborn to not do the obvious. I did:

[[NSWokspace sharedWorkspace] setIcon:someIcon forFile:someFile options:0];

to set the image icon for the folder. I from then I did com.apple.sidebarlists.plist NSUserDefaults appending, and restarted Finder through Apple Events. That made it all work.

jopes
Don’t do that. Do what Peter Hosey said. There is no good reason not to use the Launch Services API.
Ahruman