iOS Build a Simple iPhone App with Swift View Controllers and Views Using IBAction to Execute Methods

Clicking the button in the simulator throws an error.

I followed his steps exactly, but I get an error when I click the button we built in this video.

Here is what the error looks like. https://www.dropbox.com/s/8044m370jyoxfrz/Screenshot%202017-01-23%2022.28.59.png?dl=0

2 Answers

David Papandrew
David Papandrew
8,386 Points

That type of error usually indicates some sort of problematic outlet connection. If you are familiar with the storyboard editor in Xcode, go to the project's storyboard and then open the "document outline" and then on the document outline find the "View Controller" in the hierarchy. Right click and you'll see a popup panel that includes a section labeled "Outlets". It's possible you have a duplicate outlet listed there (maybe you only partially deleted an earlier outlet?). I can't know without seeing the output of this panel, but that is a good place to check first.

If you do see a duplicate or incomplete outlet, you can delete it by clicking on the "x" on this popup panel.

Good luck.

That was it. So deleting the @IBoutlet line of code does not actually delete the connection?

David Papandrew
David Papandrew
8,386 Points

Yeah, unfortunately you need to delete the code as well as the outlet connection in Interface Builder. A bit of a pain if you ask me, but at least now you know for the future. There are a few other situations like that in Xcode where you need to delete things in multiple places.