Search code examples
objective-cmacoscocoanstableviewnscell

Why does NSTableView use NSCell instead of NSView?


This may be a general discussion instead of a real question. When I started using NSTableView and NSOutlineView, I thought : oh, a instance of NSView may do almost everything. So I return a NSView instance in my delegate and dataSource.

Of couse it did not work and I realized that NSTableView consitsts of instances of NSCell which inherits directly from NSObject.

I sensed that it may be important to understand why Cocoa constructed NSTableView based on NSCell but NSView. But few documents explain it clearly. Therefore I turn to Stackoverflow. Does anyone know that? Thank you at advance!


Solution

  • You can switch to a view based NSTableView or NSOutlineView in the inspector

    Change from Cell to View Based

    The reason for a cell based cell would be if your only want to display a string. If you only want to display a string it would be a waste of resources to init a whole view to each cell. It is basically about memory control vs. what you need to display.