Search code examples
objective-cmacoscocoadrag-and-dropnsoutlineview

Drag and Drop methods for NSOutlineView are not getting called


I'm trying to enable drag&drop for NSOutlineView in my OSX app. The only thing I need to be able to drop is png image from the Finder.

I have myOutlineView and a controller which is a data source and a delegate of my outline view.

In my outline view controller I have these three methods:

-(BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard

 -(NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id < NSDraggingInfo >)info proposedItem:(id)item proposedChildIndex:(NSInteger)index

-(BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id < NSDraggingInfo >)info item:(id)item childIndex:(NSInteger)index{

none of them is being called...my nib is setup properly...my outline view is getting filled and all of the functionality is working except the drag&drop feature...

Any kind of help is highly appreciated!


Solution

  • Just fixed it I placed

    [[self currentOutlineView] registerForDraggedTypes:[NSArray arrayWithObjects:(NSString*)kUTTypeFileURL,kPrivateDragUTI,nil]];
    

    to the wrong spot, so my outline view couldn't register the draggable types appropriately. I placed it to

    -(void) awakeFromNib 
    

    in my outline view controller and everything is working now! :)