Best way to access data when subclassing NSTableView?

  • Hi all,

    I'm subclassing NSTableView to implement cut & paste and to catch the
    delete key. I've populated my table with bindings, and right now, I'm
    wondering about the best way to get the selection in the table for
    cutting and deleting objects.

    My application is a standard document-based one, and the table is
    part of a window in MyDocument.nib. That nib-file also contains an
    array controller that makes sure my NSMutableArray (an instance
    variable of MyDocument) shows up in the table. I've made MyDocument
    the delegate of the table, and in my -cut: method in my NSTableView
    subclass, I get the selection like this:

    NSArrayController *controller = [[self delegate] myArrayController];
    NSArray *selection = [controller selectedObjects];

    This approach requires the subclass to know the name of the array
    controller in its delegate, which limits the generality of the
    subclass considerably. Is there a more general way to get at the
    table data? It seems there must be, and I hardly think nobody else
    has solved this, so I apologize if I missed the relevant info.

    Thanks very much!

previous month september 2007 next month
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today