Update for 2015
The LSSharedFileList header says it has moved into the scope of CoreServices . In fact, if you are Cmd-Shift-O (in Xcode) and enter LSSharedFileList, go to the only result, you will see in the transition bar that the header is indeed contained in CoreServices.framework . In any case, the key is still kLSSharedFileListFavoriteItems .
Example:
+ (BOOL)appendFavoriteItemWithURL:(NSURL *)url { // Pessimism ... BOOL result = NO; // Do we have a file URL? if (url.isFileURL) { // Ask CoreServices for the favorite items list // (kLSSharedFileListFavoriteItems) LSSharedFileListRef list = LSSharedFileListCreate(NULL, kLSSharedFileListFavoriteItems, NULL); if (list) { // We've got the list, so try to append our item // (use kLSSharedFileListItemBeforeFirst vs. // kLSSharedFileListItemLast if desired) LSSharedFileListItemRef item = LSSharedFileListInsertItemURL(list, kLSSharedFileListItemLast, NULL, NULL, (__bridge CFURLRef)url, NULL, NULL); // Did it work? if (item) { // Release the item and flag success CFRelease(item); result = YES; } // Release the list CFRelease(list); } } return result; }
Using:
Joshua nozzi
source share