I am trying to implement copying and pasting of multiple objects in an NSTableView
backed by an NSArrayController
. My copy:
method looks like this:
- (IBAction)copy:(id)sender {
if (self.arrayController.selectionIndexes.count > 0) {
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
[pasteboard clearContents];
NSArray *copiedObjects = self.arrayController.selection;
[pasteboard writeObjects:copiedObjects];
}
}
When I try to perform a copy I get an error accessing the controller's selection because it returns a proxy object:
-[_NSControllerObjectProxy countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x7f88b362d580
How can I get the actual selected objects?
The answer to this is incredibly obvious: use self.arrayController.selectedObjects
instead.