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 Views and View Controllers View Controllers and IBAction

Gregory Millan
Gregory Millan
3,719 Points

Having issues with the Print button output not showing up in console

Hi,

I'm at the end of the video where Pasan is running the app and hitting the button "Show another Fun Fact"...I have the button as well, however when I click it, the string I passed through the function is not popping up in the console. Also I can hit the button once and after it doesn't allow anymore clicks. Can anybody help me out.

Whats popping up in the console is the following, which is a drop down menu of some sort:

self FunFacts.ViewController 0x00007fa292d11180 0x00007fa292d11180

In addition on the print("You pressed me!") line of code there pops up a Thread 1. breakpoint 1:1

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

}

Paul Brazell
Paul Brazell
14,371 Points

Did you by any chance put a breakpoint in your code? Its a blue-ish tab on the left side with the line numbers. That would stop execution until you step over the breakpoint or remove it. I accidentally put those in my code all the time when trying to view errors.

it looks something like this:

alt text

3 Answers

Gregory Millan
Gregory Millan
3,719 Points

I actually did have a breakpoint enabled there. I disabled it, then deleted it. However, now when I run the simulator and click the "Fun fact" button nothing prints in console. The button just clicks without any action.

Paul Brazell
Paul Brazell
14,371 Points

Is the IBAction linked to the button press?

Gregory Millan
Gregory Millan
3,719 Points

Yes I believe so. This is how my code looks.

import UIKit

class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}

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

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

}

Paul Brazell
Paul Brazell
14,371 Points

In the side bar with the line numbers on your view controller.swift file, do you see a black circle next to @IBAction func showFunFact or do you see an empty white circle. My guess is that the action isn't linked to your button anymore. I would verify and make sure they are linked.

Gregory Millan
Gregory Millan
3,719 Points

I see a black circle within a circle.

Paul Brazell
Paul Brazell
14,371 Points

Put a print statement in your view did load and see if it comes up then.