title: Error instantiating View Controller
body: <p>When I try to instantiate my ViewController with the code below (in the viewDidLoad part) I get a Thread 1: EXC_BAD_ACCESS when running the app on the self.present line. (I'm a beginner to coding)</p>
  
  <p>EDIT: So I provide my entire code here to see where it goes wrong. I shifted the code to viewDidLoad of my Second View Controller now. Now the app starts up, however when I press the "enter" Button, I get a "Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value" error..</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import UIKit
  
  class ViewController: UIViewController {
  
      @IBOutlet weak var progressBarView: ProgressBarView!
      
      @IBOutlet weak var progressBarView1: ProgressBarView1!
      
      
      override func viewDidLoad() {
          super.viewDidLoad()
  // updaten van de progressbar
          progressBarView.progress = CGFloat(percProgress())
          progressBarView1.progress = CGFloat(0.5)
  
  // een constante maken die de daystogocalc Int van de berekening verderop in een String cast
          let daysToGoCalcString = String(daysToGoCalc())
  
  // updaten van het label daysToGo
          daysToGo.text = "Still \(daysToGoCalcString) days to go"
  
  // updaten van het label textPercentage
          let textPercentage = NSString(format: "%.0f", (percProgress() * 100))
          percentageDays.text = String(textPercentage) + "%"
      
      }
      
  
          
  
      
          
      @IBOutlet weak var daysToGo: UILabel!
      
      @IBOutlet weak var percentageDays: UILabel!
      
      @IBOutlet weak var firstGoalLabel: UILabel!
      
      
      @IBAction func unwindToGoals(unwindSegue: UIStoryboardSegue) {
          
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
      // Automatische datumberekening
      let today = Date()
      let calendar = Calendar.current
      // Dagnummer van het jaar
      var todayNumber: Int {
          get {
              return calendar.ordinality(of: .day, in: .year, for: today)!
          }
      }
      // FLOAT MAKER: onderstaande maakt een Float van het dagnummer (nodig voor de Progress Bar uiteindelijk)
      var todayFloat: Float {
          get {
              return Float(todayNumber)
          }
      }
      // KWARTAAL PROGRESSIE: deze functie checkt eerst in welk kwartaal je zit, en vervolgens de voortgang in dat kwartaal in een float
      func percProgress() -&gt; Float {
          
          if todayNumber &lt; 91 {
              return todayFloat / 90
          }
          else if todayNumber &lt; 182 {
              return (todayFloat - 90) / 91
          }
          else if todayNumber &lt; 274 {
              return (todayFloat - 181) / 92
          }
          else {
              return (todayFloat - 273) / 92
          }
      }
      
      // Bereken aantal dagen te gaan in kwartaal
      func daysToGoCalc() -&gt; Int {
          
          if todayNumber &lt; 91 {
              return 90 - todayNumber
          }
          else if todayNumber &lt; 182 {
              return 181 - todayNumber
          }
          else if todayNumber &lt; 274 {
              return 273 - todayNumber
          }
          else {
              return 365 - todayNumber
          }
      }
      
  
  }
  
  
  
  
  // SECOND VIEW CONTROLLER
  
  class SecondViewController: UIViewController {
      
      override func viewDidLoad() {
          super.viewDidLoad()
      
          firstGoaltext.delegate = self
          firstGoalStart.delegate = self
          firstGoalEnd.delegate = self
          
          secondGoaltext.delegate = self
          secondGoalStart.delegate = self
          secondGoalEnd.delegate = self
          
          thirdGoaltext.delegate = self
          thirdGoalStart.delegate = self
          thirdGoalEnd.delegate = self
          
          fourthGoaltext.delegate = self
          fourthGoalStart.delegate = self
          fourthGoalEnd.delegate = self
          
          fifthGoaltext.delegate = self
          fifthGoalStart.delegate = self
          fifthGoalEnd.delegate = self
      
          // INSTANTIATE VIEWCONTROLLER
          let storyboard1 = UIStoryboard(name: "Main", bundle: nil)
          var firstController: UIViewController {
              get {
                  return storyboard1.instantiateViewController(withIdentifier: "myViewControllerIdentifier")
              }
          }
          
          self.present(firstController, animated: true, completion: nil)
          
      }
  
  
  
      @IBOutlet weak var firstGoaltext: UITextField!
      @IBOutlet weak var firstGoalStart: UITextField!
      @IBOutlet weak var firstGoalEnd: UITextField!
      
      @IBOutlet weak var secondGoaltext: UITextField!
      @IBOutlet weak var secondGoalStart: UITextField!
      @IBOutlet weak var secondGoalEnd: UITextField!
      
      @IBOutlet weak var thirdGoaltext: UITextField!
      @IBOutlet weak var thirdGoalStart: UITextField!
      @IBOutlet weak var thirdGoalEnd: UITextField!
      
      @IBOutlet weak var fourthGoaltext: UITextField!
      @IBOutlet weak var fourthGoalStart: UITextField!
      @IBOutlet weak var fourthGoalEnd: UITextField!
      
      @IBOutlet weak var fifthGoaltext: UITextField!
      @IBOutlet weak var fifthGoalStart: UITextField!
      @IBOutlet weak var fifthGoalEnd: UITextField!
      
      @IBAction func enter(_ sender: Any!) {
          
          let vc1 = ViewController()
          vc1.firstGoalLabel.text = firstGoaltext.text
      }
      
      override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
          firstGoalStart.resignFirstResponder()
      }
      
  }
  
  
  
  extension SecondViewController : UITextFieldDelegate {
      
      func textFieldShouldReturn(_ textField: UITextField) -&gt; Bool {
          textField.resignFirstResponder()
          return true
      }
      
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>What I am doing wrong here?</p>