La mise en œuvre de glisser et déposer dans NSTableView

Quelqu'un peut m'aider à mettre en œuvre de glisser et de les déposer dans un NSTableView? J'ai utilisé ce code ci-dessous, mais ces méthodes ne sont pas appelé lors de l'exécution.

- (BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard*)pboard
{
    //Copy the row numbers to the pasteboard.
    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
    [pboard declareTypes:[NSArray arrayWithObject:@".gif"] owner:self];
    [pboard setData:data forType:@".gif"];
    return YES;
}

- (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id <NSDraggingInfo>)info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)op
{
    //Add code here to validate the drop

    if (row > [ m_imageArray count])
        return NSDragOperationNone;

    if (nil == [info draggingSource]) //From other application
    {
        return NSDragOperationNone;
    }
    else if (self == [info draggingSource]) //From self
    {
        return NSDragOperationNone;
    }
    else //From other documents 
    {
        [tv setDropRow: row dropOperation: NSTableViewDropAbove];
        return NSDragOperationCopy;
    }

    NSLog(@"validate Drop");
    return NSDragOperationCopy;
}


- (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id <NSDraggingInfo>)info
              row:(NSInteger)row dropOperation:(NSTableViewDropOperation)operation
{
    NSPasteboard* pboard = [info draggingPasteboard];
    NSData* rowData = [pboard dataForType:@".gif"];
    NSIndexSet* rowIndexes = [NSKeyedUnarchiver unarchiveObjectWithData:rowData];
    NSInteger dragRow = [rowIndexes firstIndex];

    //Move the specified row to its new location...
}

OriginalL'auteur akhil gupta | 2011-05-10