0
votes

I'm writing an application using NSWindowDelegate. However, when I resize the window, it doesn't call function:

func windowDidResize(notification: NSNotification)

This is my class

class ViewController: NSViewController, NSWindowDelegate {}

and the storyboard:

This is my storyboard

I linked delegate to my window. But it doesn't work. Can you help me fix the error? Thank you.

1

1 Answers

0
votes

You've declared your window delegate with:

class ViewController: NSViewController, NSWindowDelegate {}

When your screenshot shows the window controller, not the view controller, as being designated as the delegate.

Set your window controller to be the delegate recipient. E.G.:

class MyWindowController : NSWindowController, NSWindowDelegate {}