>And I also set my application's delegate and overrode windowWillResize(_ sender: NSWindow, to frameSize: NSSize) -> NSSize. That also is never called.
You set the application's delegate? Did you set the window's delegate? There are several delegate methods related to size changes declared in NSWindow.h (under NSWindowDelegate) including:
- (void)windowDidResize:(NSNotification *)notification;
- (void)windowWillStartLiveResize:(NSNotification *)notification NS_AVAILABLE_MAC(10_6);
- (void)windowDidEndLiveResize:(NSNotification *)notification NS_AVAILABLE_MAC(10_6);
According to the appkit release notes, you may want to register for the notifications (not set NSWindowDelegate) if you are using NSWindowCOntroller in conjunction with your window, since they are putting things on lock down.
With that said, I ususally don't use the window delegate methods to do things (other than maybe fade out on willStartLiveResize, and fade in after windowDidEndLiveResize).
Otherwise, when I do manual layout, since there is no viewDidLayoutSubviews method on macOS, I just listen for the window's content view frame change:
-(void)viewDidLoad
{
[super viewDidLoad];
//assume this view controller is the window's contentViewController.
self.view.postsFrameChangedNotifications = YES;
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(viewFrameDidChange:)
name:NSViewFrameDidChangeNotification
object:self.view];
}
-(void)viewFrameDidChange:(NSNotification*)note
{
NSLog(@"frame changed");
}
-(void)dealloc
{
[[NSNotificationCenter defaultCenter]removeObserver:self
name:NSViewFrameDidChangeNotification
object:self.view];
}
I know there's viewDidLayout or something on a view controller on macOS, but I recall running into some issues making changes in this method, so I just avoid it.