6

That's the button action:

    @IBAction func readyPressed(sender: NSButton) {

    self.dismissController(Hardness)
    println(1)
    self.performSegueWithIdentifier("manual", sender: self)
    }

When I press the button, println works, segue works, but NSViewController "Hardness" doesn't close

4 Answers4

26

Try this line to close the window: self.view.window?.close()

Schemetrical
  • 5,506
  • 2
  • 26
  • 43
Younes Essabri
  • 269
  • 3
  • 3
2

You must add Action from button to First Responder - dismissController:

screenshot

Tom Fuller
  • 5,291
  • 7
  • 33
  • 42
-1

you can try

NSViewController().dismiss(vc).

the viewcontroller to be dismissed should be passed as argument and the caller could be any NSViewController object.

pranav
  • 499
  • 5
  • 6
-11

Please try using

self.dismissViewControllerAnimated(true, completion: {});

or use

navigationController.popViewControllerAnimated(true)

as presented here

how to dismiss a view controller in swift

Community
  • 1
  • 1
Alex
  • 122
  • 1
  • 7
  • 8
    This should not be the accepted answer, since the question is for MacOS not iOS. Please read more carefully it doesn't say UIViewController but NSViewController. – Borzh Apr 10 '15 at 15:56