Problem with binding selectionIndexes of an NSArrayController
Problem with binding selectionIndexes of an NSArrayController
- Subject: Problem with binding selectionIndexes of an NSArrayController
- From: Michael Norris <email@hidden>
- Date: Sun, 29 Jul 2007 13:47:33 +0200
Hi there
I would be very glad for anyone's help here - I've been using
Objective-C/Cocoa for a while, but still find aspects of it that
mystify me.
Anyway, I have a project which contains two NSArrayControllers, one
called "ItemSets" and one called "ScreenData". Each ItemSet object in
the ItemSets array has an ivar called "selectedScreen", an int which
is intended to store which screenData object is selected in the
ScreenData array. The idea is that when the user selects a different
itemSet object, a different screenData object will be displayed in
the inspector.
To do this, I bound ScreenData's selectionIndexes to my ItemSets
controller with controller key "selection" and model key path
"selectedScreenIndexes". Then, in my ItemSets object, I set
"selectedScreenIndexes" to be a dependent key of "selectedScreen",
and the selectedScreenIndexes accessor generates an NSIndexSet
containing one index: selectedScreen. (If you're wondering why I need
the int at all, it's because some controllers on my window are bound
to it).
In my ItemSet object -init routine, I call [self setSelectedScreen:
3], which is fine. But when I then tell the ItemSets array controller
to addObject: I get a call to setSelectedScreenIndexes, with an
indexSet containing a single index of 0.
I can't quite see why addObject: triggers setSelectedScreenIndexes
(is it because the key "ItemSets.selection" has changed?), or why it
contains a single index of 0, but I would like to keep it at the "3"
I set in the initialization routine. In fact, I would ideally like
the selectedScreenIndexes to be a read-only key, but I realise that's
not possible.
Sorry for the slightly crummy explanation; hope you can help!
Thanks again
Michael
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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