I have an application which has to be shown on Users list of Finder's sidebar on installation.
So on installation code, I have added one more dictionary object to Library -> Preferences-> com.apple.sidebarlists.plist.
.
i.e., in useritems -> customListItems
of plist.
If I see the plist addition everything looks correct.
On relaunching the Finder.app, it is expected to ge开发者_JAVA技巧t that item added in the side bar of Finder. But I am not able to see any change happening instead the plist is overridden with the old items. I tried trashing Finder cache and running the code. still no luck :( Any pointers to what I am missing please. Thanks in advance!
Use LSSharedFileList. Add an item to the Finder/Save dialog sidebar
-(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);
}
精彩评论