I am trying to set up a very simple drag and drop for my NSTableView. There is one column in the table view (with a custom cell). The column is associated with an NSArrayController, and the array of the contents of the array controller is bound to an NSArray on my controller object. Data is displayed in the table accurately. I connected the outputs dataSourceand delegateviews of the table to my controller object, and then implemented these methods:
- (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard
{
NSLog(@"dragging");
return YES;
}
- (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id <NSDraggingInfo>)info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)op
{
return NSDragOperationEvery;
}
- (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id <NSDraggingInfo>)info
row:(NSInteger)row dropOperation:(NSTableViewDropOperation)operation
{
return YES;
}
I also registered drag and drop types in -awakeFromNib:
#define MyDragType @"MyDragType"
- (void)awakeFromNib
{
[super awakeFromNib];
[_myTable registerForDraggedTypes:[NSArray arrayWithObjects:MyDragType, nil]];
}
, -tableView: writeRowsWithIndexes: toPasteboard: . , , . , ? -, , ?
EDIT: . NSTextFieldCell. , ?