• 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: NSUserDefaults for another Application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSUserDefaults for another Application


  • Subject: Re: NSUserDefaults for another Application
  • From: Keith Duncan <email@hidden>
  • Date: Thu, 26 Jul 2007 11:03:38 +0100

You can use CFPreferences to do this. The snippets below show setting and getting a value from a TextField:

appID = CFSTR("uk.co.watershed.communicate.client");
....
/* initialise the Full name field */
value = CFPreferencesCopyAppValue( CFSTR("WSPublishUserFullName"), appID);
if (value && CFGetTypeID(value) == CFStringGetTypeID()) {
[fullName setStringValue:(NSString *)value];
....


and saving values...

....
CFPreferencesSetValue( CFSTR("WSPublishUserFullName"),
[fullName stringValue],
kCFPreferencesAnyApplication,
kCFPreferencesCurrentUser,
kCFPreferencesAnyHost);

I could do that but it would be a lot of code to load and save every value in the preference file.


I have tried using NSUserDefaults to get the persistentDomainForName using the bundle id which works fine for loading the prefs, but when it comes to saving the prefs with setPersistentDomain:forName: it doesn't.

Say I have a key-object pair present in the dictionary after loading it and I remove that object at runtime, when saving the preference dictionary using setPersistentDomain:forName: the key-object pair remains in the preference file. I assume that my own alloc'd NSUserDefaults objects also register for the application termination notification and synchronize then without being explicitly told to?

- Keith

- Keith
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSUserDefaults for another Application
      • From: Michael Nickerson <email@hidden>
References: 
 >NSUserDefaults for another Application (From: Keith Duncan <email@hidden>)
 >Re: NSUserDefaults for another Application (From: Benjamin Miller <email@hidden>)

  • Prev by Date: floating point NSBitmapImageRep
  • Next by Date: Re: Is pointer syntax logical?
  • Previous by thread: Re: NSUserDefaults for another Application
  • Next by thread: Re: NSUserDefaults for another Application
  • Index(es):
    • Date
    • Thread