CFP引用任何主机和任何应用程序域的行为 [英] CFPreferences any-host and any-application domain behavior

查看:55
本文介绍了CFP引用任何主机和任何应用程序域的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用CFPreferences在osx上设置首选项时,有一些不同之处

When using CFPreferences to set preferences on osx, there are different Preference Domains.

通过阅读苹果开发指南,我了解到对于当前用户当前应用当前主机首选项,它将存储在〜/Library/Preferences/<应用程序捆绑包名称> .plist .对于任何用户当前应用当前主机首选项,它将存储在/Library/Preferences/<应用程序包名称 >.plist.

By reading the apple development guide, I understand that for current-user, current-application, current-host preference, it will be stored in ~/Library/Preferences/< application bundle name >.plist. And for any-user, current-application, current-host preference, it will be stored in /Library/Preferences/< application bundle name >.plist.

但是在哪里存储其他域组合的首选项?例如当前用户,当前应用程序,任何主机?首选项是否会在设置的时间内传播( CFPreferencesSetAppValue ,然后同步)到〜/Library/Preferences/<连接到本地网络并以当前用户身份登录的所有主机上的应用程序捆绑包名称> .plist ?还是在查询所有主机时在读取过程中完成了魔术(但是在这种情况下,如何处理来自不同主机的冲突首选项)?

But where to store preferences for other domain combinations? For example current-user, current-application, any-host? Will the preferences be propagated during set time (CFPreferencesSetAppValue follow by synchronize) to ~/Library/Preferences/< application bundle name >.plist on all hosts that are connected to the local network and logged in as the current user? Or the magic is done during read when all hosts are consulted (but how to handle conflict preferences from different hosts in that case)?

针对任何应用程序域的相同问题,首选项将存储在诸如当前用户,任何应用程序,当前主机之类的域中?

Same question for the any-application domain, where will the preference get stored for domain such as current-user, any-application, current-host?

推荐答案

首选项的默认"是当前用户、当前应用程序、任何主机.以捆绑包名称 com.example 为例,这些首选项将存储在

The "default" for preferences is current-user, current-application, any-host. Using the bundle name com.example for an example, these preferences would be stored at

~/Library/Preferences/com.example.plist

使此任何主机"成为假设的前提是您的主目录存储在网络共享上.没有其他机制可在计算机之间进行同步.一般来说,除非您要设置一个确实需要特定于用户所在物理机的值,否则应始终使用任何主机.

What makes this "any-host" is the assumption that your home directory is stored on a network share. There is no additional mechanism to synchronize it across computers. Generally speaking, you should always use any-host unless you are setting a value which really does need to be specific to the physical machine the user is sitting at.

为当前主机设置的首选项存储在 ByHost 目录下,其文件名包括计算机的UUID,例如:

Preferences which are set for the current host are stored under the ByHost directory, with a file name that includes a UUID for the computer, such as:

~/Library/Preferences/ByHost/com.example.74263C97-28D5-4AF0-8E7A-3169F1CCB545.plist

为所有应用程序设置的首选项存储在捆绑包名称 .GlobalPreferences 下,例如:

Preferences which are set for all applications are stored under the bundle name .GlobalPreferences, e.g:

~/Library/Preferences/.GlobalPreferences.plist

以及类似地,对于所有应用程序,当前主机:

and similarly for all applications, current-host:

~/Library/Preferences/ByHost/.GlobalPreferences.74263C97-28D5-4AF0-8E7A-3169F1CCB545.plist

为所有用户设置的首选项遵循相同的模式,除了/Library/Preferences 下.

这篇关于CFP引用任何主机和任何应用程序域的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆