从可可编辑系统首选项 [英] Edit system preferences from cocoa

查看:198
本文介绍了从可可编辑系统首选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用可可编程编辑系统偏好?是否需要一些框架?我需要这样做以更改全局代理设置。此外,我的应用程序是沙箱。是否有任何示例代码如何做到这一点?谢谢你的帮助。

Is there any way to edit system preferences programmatically using cocoa? Is there some framework required? I need to do this to change the global proxy settings. Also, my app is sandboxed. Is there any sample code on how to do this? Thanks for your help.

推荐答案

您正在寻找系统配置框架,但这不容易。我不认为这是可能的沙盒应用程序,因为它需要root权限。 (就像您必须以管理员身份验证,以修改系统偏好设置的网络窗格中的设置。)请参阅系统配置编程指南。其中,他们说:

You're looking for the System Configuration framework, but it's not going to be easy. I don't think it's possible for a sandboxed app, because it requires root privilege. (Just like you have to authenticate as an admin to modify settings in the Network pane of System Preferences.) See the System Configuration Programming Guidelines. Among other things, they say:


需要创建或重复集合,或激活或
停用服务的应用程序有更多复杂的任务。他们必须使用
低级配置API。此外,要开发这些
应用程序,您必须理解并使用系统配置
模式来解释和构建描述新集合
和服务的字典。

Applications that need to create or duplicate sets, or activate or deactivate services have a more complicated task. They must use the low-level configuration APIs. In addition, to develop these applications you must understand and use the System Configuration schema to interpret and build dictionaries that describe the new sets and services.

同样重要的是要意识到修改网络首选项(在
换句话说,更改持久存储),您的应用程序必须
获取root权限。这不是一个简单的任务;对于更多的
信息,您可以阅读授权服务编程指南和
查看代码示例AuthSample和MoreAuthSample可用
http://developer.apple.com/samplecode/Security/idxAuthorization-date.html

It’s also important to realize that to modify network preferences (in other words, to change the persistent store), your application must acquire root privileges. This is not a trivial task; for more information, you can read Authorization Services Programming Guide and review the code samples AuthSample and MoreAuthSample available at http://developer.apple.com/samplecode/Security/idxAuthorization-date.html.

目前,低级配置API非常基本,而且
有点难以使用。实际上,为了执行常见操作,例如
创建一个新集合,您必须将系统配置API
与I / O Kit访问相结合。在未来版本的Mac OS X中,System
配置框架可以提供更高级的API来执行这样的
网络配置任务。

Currently, the low-level configuration APIs are very basic and somewhat difficult to use. In fact, to perform common operations, such as creating a new set, you must combine the System Configuration APIs with I/O Kit access. In future versions of Mac OS X, the System Configuration framework may provide higher-level APIs to perform such network-configuration tasks.

它继续推荐 MoreSCF示例代码,但它已被放到旧文档部分。

It goes on to recommend the MoreSCF sample code, but it's been relegated to the legacy documentation section.

这篇关于从可可编辑系统首选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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