可以在沙盒模式下将文件夹添加到finder的侧边栏吗?

时间:2015-04-04 05:59:03

标签: cocoa sandbox finder appstore-sandbox

启用我的应用程序的沙盒时,我无法将新文件夹添加到Finder的侧边栏。代码打击仅在禁用沙盒时才有效。是否可以在启用沙盒的情况下向Finder添加书签项目?

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

0 个答案:

没有答案