Take the 2-minute tour ×

I've got implemented Drag and Drop from Finder to my app to NSTableView, and I created link to document, etc.

But, I want to make delete operation by drag item from NSTableView and drop this row onto Trash icon. How can I do this correctly? How enable drop onto trash?

share|improve this question
The Trash in the Dock isn't an application. –  Peter Hosey Jan 22 '13 at 10:06

1 Answer 1

up vote 3 down vote accepted

(It's been a long time since I've done this, and I'm doing it from memory and a glance at the docs. If this doesn't work, let me know and I'll double check w/ code.)

In draggingSession:sourceOperationMaskForDraggingContext: you should include NSDragOperationDelete as one of the legal operations. You will then receive NSDragOperationDelete back in your draggingSession:endedAtPoint:operation: to indicate that the item was dropped on the trash.

share|improve this answer
I've got methods in NSTableView - (void)tableView:(NSTableView *)tableView draggingSession:(NSDraggingSession *)session endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation but i've see that there i could only read that operation == NSDragOperationDelete, but i can't move it to trash. Icon is still the same, should be darker. On this method - (NSDragOperation)tableView:(NSTableView *)tableView validateDrop:(id<NSDraggingInfo>)info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)dropOperation I returned `NSDragOperationDelete. –  Tomasz Szulc Jan 21 '13 at 23:07
I don't understand the comment "but I can't move it to trash." If you're receiving NSDragOperationDelete, then it's your job to delete the element from your data and tell the table to update. Can you describe the symptom more clearly? –  Rob Napier Jan 22 '13 at 15:33
draggingSession:sourceOperationMaskForDraggingContext: This method is not called at dragging or droping time. That's why i did not receive any operation in method draggingSession:endedAtPoint:operation: In this method operation return me 0 Can you help me please ? –  Dev Sep 6 '13 at 14:15
Are you building for at least 10.7? If you're building for 10.6 or earlier, you need to use draggingSourceOperationMaskForLocal:. Read the Overview in developer.apple.com/library/mac/documentation/cocoa/reference/… –  Rob Napier Sep 6 '13 at 14:54

Your Answer


