Alessandro
Alessandro

Reputation: 199

How to dismiss NSViewController when NSButton is clicked programmatically

How can I dismiss a NSViewController when a subview NSButton is clicked?

I can't access to NSViewController from function of NSButton mouseDown so I can't write a code similar to:

 self.viewController.dismissController(self)

I need to set this programmatically, the same result when you connect via Assistant Editor a NSButton Action to its owner ViewController.

Upvotes: 1

Views: 776

Answers (1)

Aaron
Aaron

Reputation: 889

You can manually set the target and action on controls in code.

In your view controller:

self.button.target = self; self.button.action = @selector(dismissController:);

Should be good to go.

Upvotes: 1

Related Questions