• 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
Bindings NSArrayController is changing selectionIndex
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bindings NSArrayController is changing selectionIndex


  • Subject: Bindings NSArrayController is changing selectionIndex
  • From: Tod Cunningham <email@hidden>
  • Date: Sun, 19 Sep 2004 19:19:11 -0400

The array controller is changing the value of its selectionIndex even though "selects inserted objects" (selectsInsertedObjects) is off. I setup an observer to watch the controllers selectionIndex and watched it through an iteration of adding a new object (addObject).

	[logArrayController addObserver:self
						 forKeyPath:@"selectionIndex"
							options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld
							context:nil];

One thing I noticed is that the observeValueForKeyPath method doesn't contain any changed values for the selectionIndex. Both the old and new values will show up as NSNull. So I look at the selectionIndex value directly:

	unsigned rowIndex = [logArrayController selectionIndex];

The method observeValueForKeyPath gets called twice during the addObject operation:

	1. selectionIndex changes to to end of end of the array
	2. selectionIndex changes to NSNotFound

Should selectionIndex be changing?

- Tod

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Bindings NSArrayController is changing selectionIndex
      • From: Scott Stevenson <email@hidden>
  • Prev by Date: find name of hard drive that system folder resides on in Cocoa
  • Next by Date: Re: Using External C Libraries with Objective-C
  • Previous by thread: Re: find name of hard drive that system folder resides on in Cocoa
  • Next by thread: Re: Bindings NSArrayController is changing selectionIndex
  • Index(es):
    • Date
    • Thread