Re: Removing *other* app default?!?
Re: Removing *other* app default?!?
- Subject: Re: Removing *other* app default?!?
- From: "Louis C. Sacha" <email@hidden>
- Date: Fri, 16 Apr 2004 20:08:48 -0700
Hello...
This may sound kind of odd, but I think the functionality you're
looking for is available in the ScreenSaver API (which uses obj-C),
specifically ScreenSaverDefaults.
The docs are in the installed Developer Documentation at:
/Developer/Documentation/UserExperience/Reference/ScreenSaver/ObjC_classic/index.html
You would probably use the defaultsForModuleWithName: class method
using the bundle identifier of the other application you want to
change the prefs for.
Hope that helps,
Louis
Hi all,
I need to set up defaults for *another* app. So far as documentation
goes (and so far as I haven't overlooked something obvious),
NSUserDefaults can't do that, so one has to use those ugly functions --
something like
static BOOL deleteDisableForSig(NSString *sig) {
CFPreferencesSetValue((CFStringRef)@"MyDefaultName", NULL,
(CFStringRef)sig, kCFPreferencesCurrentUser,
kCFPreferencesCurrentHost);
return CFPreferencesSynchronize((CFStringRef)sig,
kCFPreferencesCurrentUser, kCFPreferencesCurrentHost);
}
All right, it runs, and returns true to confirm the value was deleted.
Only it is not! If I check it from Cocoa or using "defaults", the old
value sticks. For example, this version
static void deleteDisableForSig(NSString *sig) {
NSLog(@"deleting for %@",sig);
CFPreferencesSetValue((CFStringRef)OCSHDisableHacks, NULL,
(CFStringRef)sig, kCFPreferencesCurrentUser,
kCFPreferencesCurrentHost);
BOOL b=CFPreferencesSynchronize((CFStringRef)sig,
kCFPreferencesCurrentUser, kCFPreferencesCurrentHost);
NSLog(@"deleted %d",b);
NSLog(@"now it is
%@",CFPreferencesCopyValue((CFStringRef)OCSHDisableHacks,
(CFStringRef)sig, kCFPreferencesCurrentUser,
kCFPreferencesCurrentHost));
NSUserDefaults *def=[NSUserDefaults standardUserDefaults];
NSLog(@"but Cocoa sees %@",[[def persistentDomainForName:sig]
objectForKey:OCSHDisableHacks]);
[def synchronize];
NSLog(@"still it is
%@",CFPreferencesCopyValue((CFStringRef)OCSHDisableHacks,
(CFStringRef)sig, kCFPreferencesCurrentUser,
kCFPreferencesCurrentHost));
NSLog(@"still Cocoa sees %@",[[def persistentDomainForName:sig]
objectForKey:OCSHDisableHacks]);
}
adamantly writes out
2004-04-16 23:02:58.837 TestApp[2801] deleting for com.apple.TextEdit
2004-04-16 23:02:58.837 TestApp[2801] deleted 1
2004-04-16 23:02:58.837 TestApp[2801] now it is (null)
2004-04-16 23:02:58.837 TestApp[2801] but Cocoa sees true
2004-04-16 23:02:58.838 TestApp[2801] still it is (null)
2004-04-16 23:02:58.839 TestApp[2801] still Cocoa sees true
Any idea what am I doing wrong? The documentation explicitly says one
can freely mix NSUserDefaults with CFPreferences...
Very grateful for any insight,
---
Ondra Hada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
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.