• 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
observing changes in an NSArrayController's selection
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

observing changes in an NSArrayController's selection


  • Subject: observing changes in an NSArrayController's selection
  • From: Chuck Musser <email@hidden>
  • Date: Sat, 24 Jul 2004 19:12:11 -0700

When I use KVO to observe my NSArrayController's selection, my observeValueForKeyPath: ofObject: change: context: method gets called, but the contents of the "change" parameter are not what I expect. This dictionary contains "kind" and "new" keys, but the value associated with the "new" key is always NSNull.

I'm registering for notifications like this:

[myArrayController addObserver:self
forKeyPath:@"selection"
options:(NSKeyValueObservingOptionNew)
context:NULL];

I do this in the awakeFromNib method in my main controller object. As it now stands, the observed array gets its selection changed and new items are added to the array.

The observeValueForKeyPath... method tries to access the changed value like this:

NSLog("changeValue distance=%d", [[changeValue distance] intValue]);

Which results in this message in the Run Console:

2004-07-24 18:59:34.059 Ride Log[578] *** -[NSNull distance]: selector not recognized
2004-07-24 18:59:34.064 Ride Log[578] Exception raised during posting of notification. Ignored. exception: *** -[NSNull distance]: selector not recognized.

Any ideas on what I'm doing wrong here?

Chuck
_______________________________________________
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.


  • Follow-Ups:
    • WORKAROUND: observing changes in an NSArrayController's selection
      • From: Chuck Musser <email@hidden>
  • Prev by Date: Re: Multiple NSTextView with Movable Splitter
  • Next by Date: Re: Multiple NSTextView with Movable Splitter
  • Previous by thread: RE:Horizontal scrolling text window problem.
  • Next by thread: WORKAROUND: observing changes in an NSArrayController's selection
  • Index(es):
    • Date
    • Thread