今天分享NSApplication、NSWindow、NSView的关系,也相当于android里的Application、Window、View:
An NSApplication object maintains a list of NSWindow objects -one for each window belonging to the application- and each NSWindow object maintains a hierarchy of NSView objects. The view hierarchy is used for drawing and handling events within a window. An NSWindow object handles window-level events, distributes other events to its views, and provides a drawing area for its views. An NSWindow object also has a delegate allowing you to customize its behavior.
NSView is an abstract class for all objects displayed in a window. All subclasses implement a drawing method using graphics functions; draw(_:) is the primary method you override when creating a new NSView subclass.
An NSApplication object maintains a list of NSWindow objects -one for each window belonging to the application- and each NSWindow object maintains a hierarchy of NSView objects. The view hierarchy is used for drawing and handling events within a window. An NSWindow object handles window-level events, distributes other events to its views, and provides a drawing area for its views. An NSWindow object also has a delegate allowing you to customize its behavior.
NSView is an abstract class for all objects displayed in a window. All subclasses implement a drawing method using graphics functions; draw(_:) is the primary method you override when creating a new NSView subclass.
本文解析了Mac应用程序的基本架构,介绍了NSApplication如何管理NSWindow对象,每个窗口又如何维护其NSView对象层次结构。NSWindow负责处理窗口级别的事件,并将其余事件分发给各个视图。
234

被折叠的 条评论
为什么被折叠?



