How do I get a multiple selection out of my NSArrayController and into an NSArray on the code side?
How do I get a multiple selection out of my NSArrayController and into an NSArray on the code side?
- Subject: How do I get a multiple selection out of my NSArrayController and into an NSArray on the code side?
- From: Scott Ellsworth <email@hidden>
- Date: Fri, 26 Nov 2004 17:43:55 -0800
Hi, all.
I am trying to activate copy and paste for my Document-based Cocoa app.
I want to copy and paste the data from my NSTableView to an external
file. Since everything else about that NSTableView is using bindings,
I figure there has to be a way to get the selected rows that way as
well, but I cannot figure out how to get an NSArray of selected objects
or selected object indices from my multiple selection.
Once I put copy: in MyDocument, the copy menu item came live. Thus, to
do the copy, all I need is that array of selected items.
Aside: the design:
I have an NSObjectController named DocumentController. Its content
outlet is hooked up to MyDocument.
Inside MyDocument, I have an NSArray called visibleWorlds. This
contains World instances to be displayed.
I have an NSArrayController called Worlds, whose content is bound to
DocumentController, model key path visibleWorlds.
I have an NSTableView. The "name" column is bound to
Worlds.arrangedObjects.attributes.name, which works great. Thus, I
know that the Worlds array controller is getting the right data, and
pumping it to the NSTableView.
I now want to get the selected worlds in that NSTableView into an
NSArray inside MyDocument, which should let me then grab them when
copy: is sent. (Indices would also work fine). I cannot figure out
how to do it.
I created an NSMutableArray called selectedWorlds inside
MyDocument.h/m. My question is how to get the selected worlds from the
NSTableView into it.
I have tried creating an NSArrayController whose content was
Worlds.selectedObjects, but I could not figure out how to bind that to
MyDocument.selectedWorlds.
What am I missing?
Scott
_______________________________________________
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