Disabling NSTableView Sorting While Using Bindings
Categories: Cocoa
Cocoa is very nice in that it gives you alot of functionality “for free”; spell checking, table sorting, text searching, font selection, etc, etc. Unfortunately it can be hard to disable the “for free” functionality; for instance, table sorting. To disable table sorting in a NSTableView using Cocoa bindings (via NSArrayController) isn’t as simple as clicking a “isSortable” checkbox in interface builder, or calling -[table setIsSortable:NO];
; the solution is less straightforward than you would expect. Apple hasn’t documented how to disable sorting in table views using bindings, so it was up to a clever programmer to figure it out. Unfortunately, his solution didn’t work for me, my custom NSCell’s setObectValue:
method kept being sent nil
for some odd reason. After a little more searching I found a solution that worked for me. Sisabling sorting when using bindings is as simple as calling [tableView unbind:@"sortDescriptors"];
; Apple, please document this type of stuff instead of leaving us to waste time figuring it out!