Removing *other* app default?!?
Removing *other* app default?!?
- Subject: Removing *other* app default?!?
- From: Ondra Cada <email@hidden>
- Date: Fri, 16 Apr 2004 23:07:17 +0200
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
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.