When your NSTableView is a drag destination, you may want to support both dragging onto existing objects (to replace them, or augment them with some new attribute the user is dragging over) and support dragging between existing objects (to insert a new one in between. To get this behavior, you need to use NSTableView's-setDropRow:dropOperation:
, like so:- (NSDragOperation) tableView: (NSTableView *) view validateDrop: (idand in the) info proposedRow: (int) row proposedDropOperation: (NSTableViewDropOperation) op { // have the table highlight on-row / between-row correctly [view setDropRow: row dropOperation: op]; // or use whatever drag operation is appropriate NSDragOperation dragOp = NSDragOperationCopy; return (dragOp); } // validateDrop acceptDrop
method, look at the operation:- (BOOL) tableView: (NSTableView *) view acceptDrop: (id) info row: (int) row dropOperation: (NSTableViewDropOperation) op { if (op == NSTableViewDropOn) { // replace existing } else if (op == NSTableViewDropAbove) { // add new } else { NSLog (@"unexpected operation (%d) in %s", op, __FUNCTION__); } // documentation doesn't actually say what this signifies return (YES); } // acceptDrop