How do I load a second view correctly in Swift?
- by slooker
I have a view that I'm trying to load in Swift like this, but it crashes with this error:
'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "DetailView" nib but the view outlet was not set.'
Here is the code I'm trying to use to load it.
Second View Controller
import UIKit
class DetailViewController: UIViewController {
@IBOutlet var nameField: UITextField
override func viewDidLoad() {
super.viewDidLoad()
}
}
Code to load the view controller:
var newViewController = DetailViewController()
@IBAction func buttonTapped(AnyObject) {
println("button tapped!")
self.presentViewController(newViewController, animated: true, nil)
}
What am I doing wrong?