OS X System Congiuration Settings, Set in Objective C
What would be the best method for configuring OS X Network Proxy preferences in Objective C? If anyone has any code examples that would be very helpful.
- Also -
I have been searching all around the interwebs and can't seem to find a good source for setting OS X Sys开发者_开发技巧tem preferences/settings with Objective C. Anyone have any good sources?
Setting Mac OS X System Preferences is widely discouraged since it decentralises [and therefore defeats the purpose of] System Preferences. There are very few applications for Mac OS X that modify system behaviour/configuration legitimately, at this point I can't even think of one.
The actual proxy information may differ between each version of OS X, but on my 10.6 system it is contained within the file:
/Library/Preferences/SystemConfiguration/preferences.plist
This is just a simple XML property list file that can be parsed and regenerated using the NSPropertyListSerialization
class. Note that the password for proxies are stored elsewhere (I think you'll need to use the standard Keychain Services to obtain the password). The file above is read-only by non-root users, and read-write only by root, therefore if you actually do want to edit the contents of this file, your application must obtain root privileges. Apple has a programming guide on gaining these privileges.
A quick look here ...:
http://osx.hyperjeff.net/Apps/apps?f=preference
... reveals ...
AMPreferencePane - Cocoa classes for creating preference panes
SS_PrefsController - Preference window Cocoa class
sysprefs - Utility to change/view the system network preferences
UKPrefsPanel - Cocoa helper class for Preference windows
Maybe there's also sample code referring to the command line tools networksetup(8) and systemsetup(8), which may perhaps be similar to ...
ncutil - Network configuration utility (src: yes)
For deploying purposes have a look at:
InstaDMG - Tool for the modular creation of deployment packages
DeployStudio - Complete workstation install/restore utility
Hyperjeff's Cocoa Literature List has a networking section as well!
HTH
精彩评论