• 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: cocoa-dev digest, Vol 2 #3323 - 6 msgs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cocoa-dev digest, Vol 2 #3323 - 6 msgs


  • Subject: Re: cocoa-dev digest, Vol 2 #3323 - 6 msgs
  • From: David Webster <email@hidden>
  • Date: Tue, 9 Dec 2003 18:08:42 +0000

>> 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: Re: PopupButton help
  • Next by Date: Re: Working with sheets...
  • Previous by thread: Multiple TableView data sources
  • Next by thread: Re: Working with sheets...
  • Index(es):
    • Date
    • Thread