Set System Preferences using Objective-C

2019-08-05 16:05发布

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?

1条回答
We Are One
2楼-- · 2019-08-05 16:35

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.

查看更多
登录 后发表回答