views:

28

answers:

1

I have an NSTableView with a single column, which gets its data through an NSArrayController bound to a Core Data entity. The data feed works great, and I have been able to get drag and drop working by implementing the methods

– numberOfRowsInTableView:
– tableView:objectValueForTableColumn:row:

as well as the specific drag and drop methods

– tableView:acceptDrop:row:dropOperation:
– tableView:writeRowsWithIndexes:toPasteboard:

But do I really have to implement the first two methods even though the tableview is fed data through the array controller? I tried commenting out my implementations, but then I get errors in the console saying "Illegal NSTableView data source". The documentation for the NSTableViewDataSource protocol says that the methods are optional if the application is using Cocoa bindings, so obviously, I'm doing something wrong.

The question: How do I make the tableview use its existing binding and still support drag and drop?

A: 

I believe you do need to implement them to silence the complaint. I believe when used with Bindings the values returned by these data source methods are ignored. So for -numberOfRowsInTableView: you can return zero; for -tableView:objectValueForTableColumn:row: you can return nil.

Joshua Nozzi
Yeah, that works. Thanks!
Frost