1

I am trying to create a full featured spreadsheet grid control for mac osx. It appears that neither NSTableView nor NSCollectionView would be appropriate, so I am looking into a custom control. From my research to this point it appears that the two main approaches would be to let the cell in the grid be derived from:

  1. NSCell
  2. NSView

Which would be more appropriate for my purpose and why?

Dharmesh Kheni
  • 71,228
  • 33
  • 160
  • 165
Sam
  • 2,745
  • 3
  • 20
  • 42

1 Answers1

2

NSCell is (informally) deprecated, so I wouldn't make anything new based on it. Go with NSView.

From the AppKit release notes for 10.10:

Gradual deprecation of NSCell

Mac OS X 10.10 takes another step towards the eventual deprecation of cells. Direct access to the cell of a control is discouraged, and methods which allow it will be formally deprecated in a subsequent release. A variety of cell-level APIs have been promoted to various Control subclasses in order to provide cell-free access to important functionality. NSLevelIndicator, NSTextField, NSSearchField, NSSlider, and NSPathControl all have new properties for this purpose. Cell-based NSTableViews are now deprecated, and view-based NSTableViews should be used instead. Matrix-based NSBrowsers are also deprecated in favor of the item-based interface.

Community
  • 1
  • 1
Tom Dalling
  • 23,305
  • 6
  • 62
  • 80
  • Other than performance (with cells allegedly being more lightweight) were there any other advantages of cells? [I understand the performance implications of views can be mitigated by accessing a queue of reusable view objects.] – Sam Nov 26 '14 at 08:20
  • Not really. I think the NSCell design was chosen mainly to reduce memory consumption, back when it mattered. These days, it just complicates things with no real benefit. – Tom Dalling Nov 26 '14 at 08:31
  • Another problem was performance, when you have a complex view hierarchy with many similar subviews. Autoresizing/redrawing became very slow. Not in our days … – Amin Negm-Awad Nov 26 '14 at 14:56
  • So having a grid with say 30 x 30 = 900 Cells where each one is a NSView derivative is going to be fine these days because performance is better? – Sam Nov 27 '14 at 08:53
  • @TomDalling I've spent quite some time trying to develop an NSView based grid and haven't been able to get it to be performant. See http://stackoverflow.com/questions/28392153/why-is-my-cocoa-nswindow-taking-such-a-long-time-to-become-active?noredirect=1#comment45134064_28392153 Despite Apple's 'gradual deprecation' of NSCell I feel compelled to explore that route now. Have you ever tried to load a view with between 1000 to 2000 subViews inside it? – Sam Feb 08 '15 at 21:12