NSCell和NSControl之间的关系/区别是什么?

时间:2023-01-23 23:53:09

I come from iOS background and when creating custom controls, you simply subclass UIControl. I am trying to build a custom NSSlider (one with 2 knobs instead of one) and noticed that there are 2 classes to deal with NSControl and NSCell.

我来自iOS背景,在创建自定义控件时,您只需子类化UIControl。我正在尝试构建一个自定义NSSlider(一个有2个旋钮而不是一个),并注意到有2个类来处理NSControl和NSCell。

Why?

1 个解决方案

#1


This is for performance reasons in the past. It made it possible to reuse cells without always creating new ones for example in a table. Additionally you did not have very deep view hierarchies, being a problem 10 years ago.

这是出于性能原因的过去。它使得重用单元格成为可能,而不必总是在表格中创建新的单元格。此外,你没有非常深入的视图层次结构,这是10年前的一个问题。

Please note that NSCell works completely different from what you know in iOS, esp. it is no view.

请注意,NSCell的工作方式与iOS中的知识完全不同,尤其是。这不是观点。

#1


This is for performance reasons in the past. It made it possible to reuse cells without always creating new ones for example in a table. Additionally you did not have very deep view hierarchies, being a problem 10 years ago.

这是出于性能原因的过去。它使得重用单元格成为可能,而不必总是在表格中创建新的单元格。此外,你没有非常深入的视图层次结构,这是10年前的一个问题。

Please note that NSCell works completely different from what you know in iOS, esp. it is no view.

请注意,NSCell的工作方式与iOS中的知识完全不同,尤其是。这不是观点。