• 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
primary/secondary selection pattern for NSArrayController?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

primary/secondary selection pattern for NSArrayController?


  • Subject: primary/secondary selection pattern for NSArrayController?
  • From: "Eric Miller" <email@hidden>
  • Date: Mon, 9 Apr 2007 12:46:22 -0600

Hey list -

Just wondering if there is a standard pattern or example for
implementing primary/secondary selection behavior using
NSArrayController. Some searching has not turned up anything so I
thought I'd ask here.

The behavior I want is that there is always an object in the
controller's selection which is the "primary" selection. Other objects
in the selection are "secondary." The user may (in my case, via a
custom view) change the primary selection, but lacking that, if there
is any selection, the controller must designate *some* object as the
primary.

So I've subclassed NSArrayController and added a primarySelection
member, which can be set as expected, and the setter enforces the
desired behavior. The problem is that there doesn't seem to be a
recommended way to hook into the controller's primitive selection
behavior. The docs discuss overriding arrangeObjects and
insertObject:atArrangedObjectIndex:, but neither of those are pinged
when selections change.

I've tried adding the controller as an observer of its own
selectionIndexes key. That works, but unless I can guarantee the order
in which notifications are sent to observers, there will be (and are)
problems. At any rate this seems like a hacky solution.

thanks!
Eric Miller
Immortal Cookie Software
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: primary/secondary selection pattern for NSArrayController?
      • From: Scott Stevenson <email@hidden>
  • Prev by Date: Re: Strange behavior with nib loading
  • Next by Date: NSTextView & NSTextTable Archiving/Unarchiving
  • Previous by thread: Using Carbon printing in Cocoa app; page setup and print sheets detached!
  • Next by thread: Re: primary/secondary selection pattern for NSArrayController?
  • Index(es):
    • Date
    • Thread