1
votes

I'm trying to learn swift code for mac OSX but there isn't much tutorials for it as ios. and i have been struggling already with closing or dismissing the view controller when i launch through a button another connected view controller

class ViewController: NSViewController {

@IBOutlet weak var username: NSTextField!
@IBOutlet weak var password: NSTextField!
@IBAction func login(sender: AnyObject) {
}


@IBAction func signUp(sender: AnyObject) {


}

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
}

override var representedObject: AnyObject? {
    didSet {
    // Update the view, if already loaded.
    }
}

}

I tried to add [self dismissModalViewControllerAnimated:YES]; to dismiss it but it doesn't work it only shows errors. if anybody could point me to somewhere i can get more information or what i'm doing wrong?

1
If this is about OS X, why do you have an "ios" tag? - matt
as far as my research went. osx and ios dev is almost the same. so i put it up maybe someone with ios background can help? no ? - Anasbzr

1 Answers

2
votes

Use

dismissViewController(self)

to dismiss the presented view controller.


About dismissViewController: from the NSViewController docs:

Dismisses a presented view controller, using the same animator that presented it.

and

In OS X, this is the universal way to dismiss a view controller, no matter how it was presented.