Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSUserDefaultsController Problem



Hello Everyone:

I have a core data app (which is NOT a document-based app). Currently, I have a Preferences Panel that has its own custom window controller (standard stuff--a separate NIB is loaded from upon selecting the Preferences menu item from the application via separate window controller (NOT the CoreDataAppDelegate) and the preferences panel is displayed) .

Each controller on the Preferences Panel is KVC bound to the Shared User Defaults (NSUserDefaultsController) and additional Target/Action connections fire methods that send notifications to registered observers. Upon relaunch of the app, the Preferences Panel retains its last settings.

In my CoreDataAppDelegate, I register the defaultValues in NSUserDefaults for the user's preferences and the same data is registered as initialValues for the NSUserDefaultsController.

Unfortunately, the Shared User Default values do not get updated when the Preferences Panel controller values are changed.

When I send hard-coded notifications to the registered observers to set the user experience from -awakeFromNib, the settings function properly. For example, the ABPeoplePickerView gets set to display name with a choice of phone, address or email through this call if I hard-code the BOOL settings tfor the notifications like so:

    NSNotificationCenter *nc;
    nc = [NSNotificationCenter defaultCenter];

    [nc postNotificationName:@"XXPhoneStateChanged"
                      object:[NSNumber numberWithBool:YES]];

    [nc postNotificationName:@"XXAddressStateChanged"
                      object:[NSNumber numberWithBool:YES]];

    [nc postNotificationName:@"XXEmailStateChanged"
                      object:[NSNumber numberWithBool:YES]];

    [nc postNotificationName:@"XXAIMStateChanged"
                      object:[NSNumber numberWithBool:NO]];

    [nc postNotificationName:@"XXHomePageStateChanged"
                      object:[NSNumber numberWithBool:NO]];


However, if I set the controllers in the Preferences Panel controllers to display only name with phone or email and then access the preferences from Shared User Defaults like so:


[nc postNotificationName:@"XXPhoneStateChanged"
object: [[[NSUserDefaultsController sharedUserDefaultsController] values]
valueForKey:XXPhoneState]];


    etc...

the values that are retrieved are the initial values that I set in the +initialize method. Thus, the Shared User Defaults values for these keys are NOT being updated from the Preferences Panel bindings.

It's probably something obvious, but what have I forgotten to do? Any help will be greatly appreciated.

Thanks in advance.

Marc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.