I'm trying to add a folder with icon in Finder sidebar using code.
CFURLRef url = (__bridge CFURLRef)[NSURL fileURLWithPath:path];
IconRef iconRef;
FSRef fref;
CFURLRef iconURLRef = (__bridge CFURLRef)[NSURL fileURLWithPath:@"/pathTo/icon.icns"];
CFURLGetFSRef(iconURLRef, &fref);
RegisterIconRefFromFSRef('SSBL', 'ssic', &fref, &iconRef);
// 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,
kLSSharedFileListItemBeforeFirst, NULL, iconRef,
url, NULL, NULL);
if (item){
CFRelease(item);
}
}
CFRelease(favoriteItems);
But a warning shows up: CFURLGetFSRef is deprecated: first deprecated in OS X 10.9
So What's the substitute?