Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is NSCell deprecating and why was it introduced in the first place?

Tags:

macos

appkit

The "Gradual deprecation of NSCell" section of AppKit Release Notes for OS X v10.10 says:

Mac OS X 10.10 takes another step towards the eventual deprecation of cells.

I heard that NSCell was introduced for performance reason. But then why it is deprecating?

like image 747
Ethan Avatar asked Oct 30 '14 01:10

Ethan


1 Answers

NSCell was introduced for performance reasons in the NeXTSTEP days on machines with a few megs of memory, when having a full NSView for every table cell was an unaffordable extravagance. In iOS, table views were dramatically simplified by using views rather than cells. In OS X 10.7, Apple started to move OS X in the same direction, and we're finally getting there.

NSCell has always been a major hassle on OS X, not the least of which because it uses NSCopyObject(), one of the most annoying functions NeXT ever wrote. It also provides a single text editor (NSText) that is shared between all text-entry views. If you're not careful, this can lead to confusing bugs when views interfere with each other via this shared object. The separation and duplication between controls and cells has always be a source of confusion among OS X devs as well.

Once upon a time, it was needed, but those days have long past. We no longer have to worry about "the overhead of a full NSView subclass" in the majority of cases. Particularly since the addition of CALayer has made drawing them so much faster.

like image 179
Rob Napier Avatar answered Nov 15 '22 19:11

Rob Napier