OSUR 10.9中不推荐使用CFURLGetFSRef

时间:2014-01-28 16:57:26

标签: macos finder

我正在尝试使用代码在Finder侧边栏中添加带图标的文件夹。

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);

但是出现警告:不推荐使用CFURLGetFSRef:OS X 10.9中首先弃用了该值 那么替代品是什么?

0 个答案:

没有答案