使用Objective-C设置系统偏好设置 [英] Set System Preferences using Objective-C

查看:164
本文介绍了使用Objective-C设置系统偏好设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是微不足道的,但是我无法在线找到任何信息:如何使用代码设置任何Apple偏好设置?我想为自己创建一个小应用程序,当我单击按钮时可以设置某些首选项.例如,我想关闭蓝牙和Wi-Fi.据我所知,这些首选项存储在/Users/fabian/Library/Preferences/com.apple.*.plist中.

This is probably trivial, however I couldn't find any information online: How can I set any Apple preference using code? I would like to create a little application for myself that sets certain preferences when I click a button. For instance I would like to turn off Bluetooth and Wi-Fi. As far as I know, these preferences are stored in /Users/fabian/Library/Preferences/com.apple.*.plist.

所以:我该如何更改这些首选项并确保已应用它们?

So: how can I change these preferences and make sure they are applied?

推荐答案

The CoreFoundation CFPreferences API allows for editing of defaults outside of the current application's defaults domain.

请注意,您可能需要管理权限才能编辑许多与网络相关的默认设置.

Note that you'll likely need administrative privileges to edit many network related defaults.

这篇关于使用Objective-C设置系统偏好设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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