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 Improving Our User Interface Adding a Pop of Color

exc_bad_instruction exc_i386_invop when adding var randomColor now it will not go away

I get the error at funFactLabel.text = factBook.randomFact()

}

on the thread page

0x1118a1ab3 <+35>: callq 0x1118f7250 ; function signature specialization <Arg[0] = Exploded, Arg[1] = Exploded> of Swift.(_fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt) -> ()).(closure #2) -> 0x1118a1ab8 <+40>: ud2
0x1118a1aba <+42>: movq $0x0, -0x10(%rbp)

in the debug panel

fatal error: unexpectedly found nil while unwrapping an Optional value

I don't know how to add files but here is the viewcontroller

import UIKit

class ViewController: UIViewController {

@IBOutlet weak var funFactLabel: UILabel!

let factBook = FackBook()
let colorWheel = ColorWheel()

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    funFactLabel.text = factBook.randomFact()

}

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


@IBAction func showFunFact() {

    view.backgroundColor = colorWheel.randomColor()
    funFactLabel.text = factBook.randomFact()
}

}

Stepan Ulyanin
Stepan Ulyanin
11,318 Points

What does your randomFact() look like?