• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Removing *other* app default?!?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing *other* app default?!?


  • Subject: Re: Removing *other* app default?!?
  • From: Charles Srstka <email@hidden>
  • Date: Fri, 16 Apr 2004 19:37:43 -0500

Am I misunderstanding what you need to do, or are -[NSUserDefaults persistentDomainForName:] and -[NSUserDefaults removePersistentDomainForName:] all you need?

Charles

On Apr 16, 2004, at 4:07 PM, Ondra Cada wrote:

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.
_______________________________________________
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.


  • Follow-Ups:
    • SOLVED (workaround): Removing *other* app default?!?
      • From: Ondra Cada <email@hidden>
References: 
 >Removing *other* app default?!? (From: Ondra Cada <email@hidden>)

  • Prev by Date: Re: Display to screen but will not print
  • Next by Date: Re: OBJ-C question
  • Previous by thread: Removing *other* app default?!?
  • Next by thread: SOLVED (workaround): Removing *other* app default?!?
  • Index(es):
    • Date
    • Thread