Using Window Notifications and Delegate Methods

The NSWindow class offers observers a rich set of notifications, which it broadcasts on such occurrences as gaining or losing key or main window status, minimizing, moving or resizing, becoming exposed, and closing. Each notification is matched to a delegate method, so a window’s delegate is automatically registered for all notifications that it has methods for. The NSWindow class also offers its delegate a few other methods, such as windowShouldClose:, which requests approval to close, windowWillResize:toSize:, which allows the delegate to constrain the window’s size, windowWillUseStandardFrame:defaultFrame:, which allows the delegate to set the window frame for zooming, and windowWillReturnFieldEditor:toObject:, which gives the delegate a chance to modify the field editor or substitute a different editor. See the individual notification and delegate method descriptions for more information.