我的主应用程序是不露面的(Dock 中和菜单栏中都没有图标),我想开发另一个应用程序来管理首选项。
我怎样才能实现这一目标(对于那些知道这个应用程序的人来说,就像 AlfredApp 一样)?
最佳答案
理论上你可以使用NSUserDefaults
的addSuiteNamed:方法。苹果的文档说,关于这个方法:
The suiteName domain is similar to a bundle identifier string, but is not tied to a particular application or bundle. A suite can be used to hold preferences that are shared between multiple applications.
无论如何,这将允许您写入该应用程序的 NSUserDefaults。
话虽如此,如果您的应用程序是沙盒的(又名:您正在为 Mac App Store 编写它),那么使用 NSUserDefaults
- 或任何其他首选项文件写入方法 - 将受到限制。因此,根据您对应用/分发方法的目标,也许您应该修改您的计划。
关于macos - 操作系统: How to have a dedicated application for managing the preferences of another one,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20731812/