How do you programmatically put folder icons on the Finder sidebar, given that you have to use a custom icon for the folder?

后端 未结 3 769
醉酒成梦
醉酒成梦 2020-12-09 00:36

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

3条回答
  •  甜味超标
    2020-12-09 01:21

    I don't know about the icons but I add items to the sidebar using the EBLaunchServices wrapper which is available open source here:

    https://github.com/Eric-Bro/EBLaunchServices

    It is very easy to use. For instance to add a mounted OSXFUSE volume to the sidebar you call:

    NSURL* volumeUrl = [NSURL fileURLWithPath:@"/Volumes/MyVolume"];
    [EBLaunchServices addItemWithURL:volumeUrl toList:kLSSharedFileListFavoriteVolumes];
    

提交回复
热议问题