• 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: Benjamin Miller <email@hidden>
  • Date: Thu, 26 Jul 2007 06:57:03 +0100


On 25 Jul 2007, at 20:38, Keith Duncan wrote:

Obviously I cannot use [NSUserDefaults standardUserDefaults] because that will return the defaults for the System Preferences app. I am unsure of how to proceed, I have read the defaults documentations topics but I am still left confused. How would I initialize an NSUserDefaults object with the correct stack of search domains for an application other than the System Preferences application? An application whose bundle identifier will be identical to that of the preference pane's bundle identifier?

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);


Benjamin



Benjamin Miller, Digital Developer
Watershed Media Centre
1 Canon's Road, Harbourside, Bristol, UK. BS1 5TX
t: +44 (0)117 927 6444, f: +44(0)117 921 3958
http://www.watershed.co.uk/
iChat-AIM: email@hidden


_______________________________________________

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: Keith Duncan <email@hidden>
References: 
 >NSUserDefaults for another Application (From: Keith Duncan <email@hidden>)

  • Prev by Date: Re: Document-based cocoa application with 2 .nibs
  • Next by Date: Re: problem with custom nsview as first responder
  • Previous by thread: NSUserDefaults for another Application
  • Next by thread: Re: NSUserDefaults for another Application
  • Index(es):
    • Date
    • Thread