Strange NSTableView drag and drop error

Discussion in 'Mac Programming' started by HexMonkey, Sep 21, 2004.

  1. HexMonkey Administrator


    Staff Member

    Feb 5, 2004
    New Zealand
    I have an NSTableView in my Cocoa application that accepts files dragged from Finder. It works fine, except when it has no items in it and the mouse goes over the top row of pixels of the NSTableView's content area while dragging (see the attached picture if this isn't clear, the red line is the area affected). When this happens, I get an error printed to the run log/console:

    ERROR: Attempt to set dropRow=0, dropOperation=NSTableViewDropOn when [0 - 0] is valid range of rows.

    Thinking it was a bug somewhere in my code, I created a new project with only the necessary code, and it still occured. The steps taken to create the project were:

    1. Create a new Cocoa application in Xcode
    2. Put an NSTableView in the main window of MainMenu.nib
    3. Create a class called "Controller" and create an outlet for the NSTableView called "tableView"
    4. Instantiate Controller
    5. Set Controller as the NSTableView's dataSource and set the NSTableView to Controller's tableView outlet.
    6. Create the files for Controller
    7. Use the code below for Controller.m

    #import "Controller.h"
    @implementation Controller
    -(NSDragOperation)tableView:(NSTableView *)tv validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row proposedDropOperation:(NSTableViewDropOperation)operation
    	[tv setDropRow: -1 dropOperation: NSTableViewDropOn];
    	return NSDragOperationCopy;
    -(BOOL)tableView:(NSTableView *)tv acceptDrop:(id <NSDraggingInfo>)info row:(int)row dropOperation:(NSTableViewDropOperation)operation
    	return YES;
    	[tableView registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, nil]];
    	[tableView unregisterDraggedTypes];
    The output of the run log when dragging a file over the affected area was:

    Since the errors occured before "validateDrop" was printed, this shows that the bug occured before validateDrop is run.

    I'm using Mac OS X 10.3.4 and Xcode 1.5.

    Obviously this isn't a huge bug, but does anyone know of a solution, or is this unpreventable?

    Attached Files:

  2. iMeowbot macrumors G3


    Aug 30, 2003
    Huh. For what it's worth, I can duplicate it, and it doesn't matter what validateDrop does or returns. It really looks like some internal debugging cruft that Apple left behind.

Share This Page