Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Simple iPhone App with Swift 2.0 View Controllers and Views Creating IBOutlets

Paul M
Paul M
16,370 Points

funFactLabel Help : fatal error: unexpectedly found nil while unwrapping an Optional value (lldb)

I get this console error in my code, fatal error: unexpectedly found nil while unwrapping an Optional value (lldb). There is also a error in the document saying "EXC_BAD_INSTRUCTION", can anyone help me?

import UIKit

class ViewController: UIViewController {


    @IBOutlet weak var funFactLabel: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()
        funFactLabel.text = "An interesting fact!" //This is where the error occurred
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @IBAction func showFunFact() {
        print("You pressed me!")
    }


}

1 Answer

Jhoan Arango
Jhoan Arango
14,575 Points

Hello :

Try reconnecting the IBoutlet "funFactLabel". Perhaps at some point it got disconnected.

Good luck