Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 通过使用objective C编辑com.apple.sidebarlists.plist向侧栏添加项目_Objective C - Fatal编程技术网

Objective c 通过使用objective C编辑com.apple.sidebarlists.plist向侧栏添加项目

Objective c 通过使用objective C编辑com.apple.sidebarlists.plist向侧栏添加项目,objective-c,Objective C,我有一个应用程序,它必须在安装时显示在Finder侧边栏的用户列表上 关于安装代码,我在Library->Preferences->com.apple.sidebarlists.plist.中又添加了一个dictionary对象。 i、 例如,在plist的useritems->customListItems中 如果我看到plist加法,一切看起来都是正确的 在重新启动Finder.app时,它会将该项目添加到Finder的侧栏中。但是我看不到任何变化,而是用旧项覆盖plist。我试图破坏Fin

我有一个应用程序,它必须在安装时显示在Finder侧边栏的用户列表上

关于安装代码,我在
Library->Preferences->com.apple.sidebarlists.plist.
中又添加了一个dictionary对象。 i、 例如,在plist的
useritems->customListItems

如果我看到plist加法,一切看起来都是正确的

在重新启动Finder.app时,它会将该项目添加到Finder的侧栏中。但是我看不到任何变化,而是用旧项覆盖plist。我试图破坏Finder缓存并运行代码。还是不走运:(请给我指点我错过了什么。 提前感谢!

使用LSSharedFileList。 将项目添加到“查找器/保存”对话框侧栏

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

尝试在分布式通知中心中侦听所有可能的通知。当项目被添加到列表中/从列表中删除时,finder可能会收到某种通知。因此,在将条目添加到plist后,您应该发送相同的通知(如果有)。谢谢Eimantas。我只是在手动将侧栏项目添加到Finder以及将项目添加到plist时尝试捕获所有通知。但在这两种情况下,我都看不到发送的任何通知。但是,当我尝试重新启动Finder.app时,在还原侧栏时会触发一个名为com.apple.Finder.LaunchNotification的通知。不是吗得到一个线索。注意:我用雪豹。看看