• 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: Subclassing NSUserDefaultsController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subclassing NSUserDefaultsController


  • Subject: Re: Subclassing NSUserDefaultsController
  • From: "email@hidden" <email@hidden>
  • Date: Sun, 20 Sep 2009 11:14:06 +0100


On 20 Sep 2009, at 10:39, Thomas Bauer wrote:

Dear List,

In some cases my application needs to modify and get the user defaults from a different user than the one it is launched under.
Since this affects not only things done programmatically, but also parts of the user interface that use bindings,
I was thinking an elegant solution would be to make the SharedDefaults controller be a subclass and
override the designated init method to either be initialized by sharedDefaults or a NSDefaults object created with initWithUser.
Unfortunately this does not seem to work on a basic level.


Even though I have assigned a custom NSUserDefaultsController subclass to the Shared Defaults object in interface builder,
the designated initializer


- (id)initWithDefaults:(NSUserDefaults *)defaults initialValues: (NSDictionary *)initialValues

is never called.

Any suggestions on why that is or if there is another maybe better way to accomplish operating on a different users defaults domain would be appreciated.

You can check out CFPreferences but it would seem to offer little hope of a solution. The preference domains include kCFPreferencesAnyUser (unsupported?) and kCFPreferencesCurrentUser.
You can always read the prefs plist directly with NSDictionary - initWithContentsOfFile. Writing changes back will no doubt reveal other issues.


I presume you are changing the defaults for your app for another user.
If so, then an alternative approach might be to consider a single shared preference dictionary that all users have access to. You could bind against that.
Thanks and regards
Thomas


_______________________________________________

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

Jonathan Mitchell

Developer
http://www.mugginsoft.com





_______________________________________________

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


References: 
 >Subclassing NSUserDefaultsController (From: Thomas Bauer <email@hidden>)

  • Prev by Date: Re: Running run loops in 10.6 (was: Need -[NSTask waitUntilExitOrTimeout:])
  • Next by Date: Re: What is the best way to call parent view controller methods from within child view controller?
  • Previous by thread: Subclassing NSUserDefaultsController
  • Next by thread: Re: Subclassing NSUserDefaultsController
  • Index(es):
    • Date
    • Thread