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 trialJosh Schlabach
1,771 PointsApp Crashes Immediately When Button Is Pressed
I followed everything that Pasan did in the video, and I get an error when I press the button. Anyone help?
Josh Schlabach
1,771 PointsMy code:
<p> import UIKit
class ViewController: UIViewController {
@IBOutlet weak var aButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
aButton.setTitle("Press me!", forState: .Normal) }
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func buttonPressed() {
view.backgroundColor = UIColor.orangeColor()
}
} </p>
The error: (lldb)
1 Answer
Kamil Manafov
4,665 Pointsfatal error: unexpectedly found nil while unwrapping an Optional value
remember optional String on that constructor
Dan Oswalt
23,438 PointsDan Oswalt
23,438 PointsPlease share the code and the error.