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

Re: NSUserDefaultsController and KVO


  • Subject: Re: NSUserDefaultsController and KVO
  • From: David Webster <email@hidden>
  • Date: Tue, 9 Dec 2003 19:31:00 +0000

Sorry for posting this twice - I'm new to lists - forgot to edit
subject line

>> I have a problem getting back a value from NSUserDefaults that I write
>> to from a popup button bound to NSUserDefaultsController. I need to
>> have my preference controller notified when this popup changes as I
>> need to set the state of other widgets based on this popup.
>
> Why not just create a binding in each of the other controls between
> their value and the same key in the Shared User Defaults controller?
>
> That way, you can let the controller architecture do all of the heavy
> lifting.
>

Because I need to intercept the change notice to do other things
besides just toggling widgets. I tried to keep the original post simple
to demonstrate the problem.

My question is still why does the change object appear to be invalid
(see original post)

- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context
{
if ([keyPath isEqualToString:@"values.DPMetricImperialState"]) {

// gets to here OK

id obj = [change objectForKey:NSKeyValueChangeNewKey];
int tag = [obj intValue];

// its gone into the ether by here but it is the objectForKey:
where I am sure it fails
}

I know I can get the value by doing the following

int tag = [[[[NSUserDefaultsController sharedUserDefaultsController]
defaults] objectForKey:@"DPMetricImperialState"] intValue];

and that works but as I am passed the change object by the above method
- why can't I use it?. Is it a bug?

Thanks
David
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: accessibility vs dock
  • Next by Date: Re: accessibility vs dock
  • Previous by thread: Re: NSUserDefaultsController and KVO
  • Next by thread: Re: NSUserDefaultsController and KVO
  • Index(es):
    • Date
    • Thread