Re: NSUserDefaults for another Application
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