今天分享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.