我正在尝试弄清楚如何以编程方式将文件夹添加到 Finder 的“位置”侧边栏。我已经看到了通过 Finder 首选项修改它的方法,但我也看到一些应用程序实际上将文件夹添加到侧边栏。
如果有人对我应该查找的内容有任何建议/指示,我将不胜感激
(这是针对 Snow Leopard 和 Leopard 的...希望它没有改变)
尝试这个:
-(void) addPathToSharedItem:(NSString *)path
{
CFURLRef url = (CFURLRef)[NSURL fileURLWithPath:path];
// Create a reference to the shared file list.
LSSharedFileListRef favoriteItems = LSSharedFileListCreate(NULL,
kLSSharedFileListFavoriteItems, NULL);
if (favoriteItems) {
//Insert an item to the list.
LSSharedFileListItemRef item = LSSharedFileListInsertItemURL(favoriteItems,
kLSSharedFileListItemLast, NULL, NULL,
url, NULL, NULL);
if (item){
CFRelease(item);
}
}
CFRelease(favoriteItems);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)