Editing defaults of other apps
Editing defaults of other apps
- Subject: Editing defaults of other apps
- From: Bill Bumgarner <email@hidden>
- Date: Wed, 20 Feb 2002 01:25:40 -0500
Actually, the Core APIs provide services for reading and manipulating
other application's defaults. Not that you would generally want to do
this, but it does work fine. Some code from SSHPassKey:
- (IBAction) configurePBXSSHPassKeyPluginAction: sender;
{
NSBundle *pbxBundle = [NSBundle bundleWithPath:
@"/Developer/Applications/Project Builder.app"];
CFStringRef pbxIdentifier = (CFStringRef) [pbxBundle bundleIdentifier]
;
CFStringRef pbxOtherPluginPref = (CFStringRef) @"PBXExtraPlugInFolders"
;
//! CFPropertyListRef otherPluginLocations;
// ensure latest stuff from PBX
CFPreferencesAppSynchronize(pbxIdentifier);
// other bundle search path
//! otherPluginLocations = CFPreferencesCopyAppValue(pbxOtherPluginPref,
pbxIdentifier);
#warning BADNESS! This is how it should work, but doesn't due to a bug in
PBX that will be fixed-- hopefully-- in the next release.
//! CFPreferencesSetAppValue(pbxOtherPluginPref, (CFStringRef)
[self cleanseAndAddPluginPath: otherPluginLocations], pbxIdentifier);
CFPreferencesSetAppValue(pbxOtherPluginPref, (CFStringRef) [self
pluginDirPath], pbxIdentifier);
// bundle configuration
CFPreferencesSetAppValue((CFStringRef) @"SSHPassKeyAppEnabled",
kCFBooleanTrue, pbxIdentifier);
CFPreferencesSetAppValue((CFStringRef) @"SSHPassKeyForceCVSToUseSSH",
kCFBooleanTrue, pbxIdentifier);
CFPreferencesSetAppValue((CFStringRef) @"SSHPassKeyAppPath",
(CFStringRef) [[NSBundle mainBundle] bundlePath], pbxIdentifier);
// write back to PBX
CFPreferencesAppSynchronize(pbxIdentifier);
}
- (IBAction) unconfigurePBXSSHPassKeyPluginAction: sender;
{
NSBundle *pbxBundle = [NSBundle bundleWithPath:
@"/Developer/Applications/Project Builder.app"];
CFStringRef pbxIdentifier = (CFStringRef) [pbxBundle bundleIdentifier]
;
CFStringRef pbxOtherPluginPref = (CFStringRef) @"PBXExtraPlugInFolders"
;
CFPreferencesAppSynchronize(pbxIdentifier);
CFPreferencesSetAppValue(pbxOtherPluginPref, NULL, pbxIdentifier);
CFPreferencesSetAppValue((CFStringRef) @"SSHPassKeyAppEnabled", NULL,
pbxIdentifier);
CFPreferencesSetAppValue((CFStringRef) @"SSHPassKeyForceCVSToUseSSH",
NULL, pbxIdentifier);
CFPreferencesSetAppValue((CFStringRef) @"SSHPassKeyAppPath", NULL,
pbxIdentifier);
CFPreferencesAppSynchronize(pbxIdentifier);
}
b.bum
On Wednesday, February 20, 2002, at 01:08 AM, jcr wrote:
Sure. Use NSUserDefaults' -persistentDomainForName: method. Be
very careful though about editing another app's defaults. (Like,
don't.)
b.bum
We gladly feast on those who would subdue us.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.