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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Philip Charlemagne](https://secure.gravatar.com/avatar/eaacc38ff19aceff9f7c5e1c5fc7a584?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Philip Charlemagne
5,813 Pointsswift thread 1: exc_bad_instruction(code=exc_i386_invop,subcode=0x0) error
In my a view controller where I changed the class to "PlaylistMasterViewController" I'm getting an error on the line where I have the code "aButton.setTitle("Press me!",forState: .Normal)".
The error says "swift thread 1: exc_bad_instruction(code=exc_i386_invop,subcode=0x0)" When I comment it out it work fine. From reading the error it appears that it is an optional and upwrapping it with a bang(!) is producing an error because there is not value there. When I look into Pasan's code, it works. Any idea what could be wrong?
import UIKit
class PlaylistMasterViewController: 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.
}
}
4 Answers
![Ricardo Rodriguez](https://secure.gravatar.com/avatar/fb61a201a71bba800fcd651659e73a29?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ricardo Rodriguez
9,758 PointsNot sure if you ever got the reply to this question but based on my experience every time you get that sort of errors is because "something is missing" compared to what is in your view controller. In this case, if you renamed things is probably that somewhere in your code something is referring to previous name of what was changed.
I came across same error myself some times and most recent one was because I was missing a LABEL that used to exist and I replaced it by mistake.
![Philip Charlemagne](https://secure.gravatar.com/avatar/eaacc38ff19aceff9f7c5e1c5fc7a584?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Philip Charlemagne
5,813 PointsInteresting, my suspicion was that I mislabeled something in the custom classes. I'll take another look at my labels. I was able to move forward and incorporate the images, I'd just like to know what went wrong.
![Vicki Lane](https://secure.gravatar.com/avatar/e522f91ff3d24f9ff40171a363d17028?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Vicki Lane
4,844 PointsI had exactly the same problem, and ended up deleting the whole project and recreating it. Having done that, my suspicion is that the problem was caused by deleting the aButton outlet reference when I was deleting the action - this may be your problem too?
It's so frustrating trying to debug issues in new languages :)
![Philip Charlemagne](https://secure.gravatar.com/avatar/eaacc38ff19aceff9f7c5e1c5fc7a584?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Philip Charlemagne
5,813 PointsThats funny that you say that. My initial code was not responding to the the first time we used the "aButton" to set the normal state "Press me!" to "button pressed." I looked up and down and couldn't figure it out. I think the error came from the change in the aButton.
![Erica Haessler](https://secure.gravatar.com/avatar/1cab4ea7e465ce60da9b5887db56c53c?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Erica Haessler
1,911 PointsIn my Main.storyboard file, when I compare the one I made with Pasan's, mine has no referencing outlet for the button.
To correct. Ctrl drag button onto the PlaylistMasterViewController.swift file right under the @IBOutlet weak var aButton: UIButton! code that is already there. then delete the old @IBOutlet weak var aButton: UIButton! text AND click the circle in the gutter and delete the old one there too.
You will see the button has a new outlet reference in the connections inspector I ran it again -> no errors.
Philip Charlemagne
5,813 PointsPhilip Charlemagne
5,813 PointsThanks Ricardo,
This was a though one. I have it in my github. I was trying to make a side by side comparison and everything seemed the same and I couldn't find the error. At the end, I ended up copying the project so that I can continue with the lesson. Thank you for trying to help.
Regards, Philip
Ricardo Rodriguez
9,758 PointsRicardo Rodriguez
9,758 PointsI totally understand Phillip, I've been there before with the exact same error and in the exact same scenario where I was comparing a code that runs VS mine (which didn't run at that time) and it was the exact same code so the difference is not actually in the actual code on the swift file but it was on a missing item/component as like the ones showed here: http://bit.ly/1zFVJQG
PS: in my case I had deleted a LABEL so code was right and 100% identical to another that run fine is just that label didn't exist.