primary/secondary selection pattern for NSArrayController?
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