Ethan
Ethan

Reputation: 18874

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

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?

Upvotes: 9

Views: 1427

Answers (1)

Rob Napier
Rob Napier

Reputation: 299445

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.

Upvotes: 13

Related Questions