SOLVED - Version 5, page 55 (pdf) - "Your First Bug" is actually a Breakpoint Error after setting alert to display currentValue

Like the title says, I’m reading from v5, and am experiencing a breakpoint error, occurring right after setting the pop up window to display currentValue.

I’m using Xcode 8.3.2 and Swift 3.1.

I have the slider connected to sliderMoved: and the hit me button connected to showAlert in the View Controller.

right after I changed the showAlert() method to:

@IBAction func showAlert() {
		let message = "The value of the slider is: \(currentValue)"
		
		let alert = UIAlertController(title: "Hello, World!",
		                              message: message,
																	preferredStyle: .alert)
		
		let action = UIAlertAction(title: "OK",
		                           style: .default, handler: nil)
		
		alert.addAction(action)
		
		present(alert, animated: true, completion: nil)
	}

I wound up with a breakpoint error at the line

let message = "The value of the slider is: \(currentValue)"

I’ve tried retracing my steps a bit and have copy/pasted the downloaded source code for that particular function but have not tried running the developer’s completed application yet. I’ve been searching around for a while to no avail. I believe I followed everything leading up to this correctly but clearly I missed something. Either that or there’s a compatibility issue with my environment.

I believe my last successful compilation was on page 49, when I utilized the print() function to print the slider value to the debugger.

I’ll revert my code to the last known good stage if I have to but if anyone can help out I’d greatly appreciate it!

Here are a few screenshots, showing what you can see after I press the “Hit Me” button:

The breakpoint error shows you how it corresponds to the AppDelegate class and some deeper layers of the application (which are all but indecipherable from my level). I’d post more photos but this is my first post.

Here is my full View Controller source for reference:

import UIKit

class ViewController: UIViewController {
	var currentValue: Int = 50
	// Declared variable to read value of slider.

	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 showAlert() {
		let message = "The value of the slider is: \(currentValue)"
		
		let alert = UIAlertController(title: "Hello, World!",
		                              message: message,
																	preferredStyle: .alert)
		
		let action = UIAlertAction(title: "OK",
		                           style: .default, handler: nil)
		
		alert.addAction(action)
		
		present(alert, animated: true, completion: nil)
	}
	
	
	@IBAction func sliderMoved(_ slider: UISlider){
		currentValue = lroundf(slider.value)
		// Recognize slider movement and round that to the nearest whole number. Assign this value to currentValue.
	}
	
}

Thanks for reading!

SOLVED!

Alright y’all, I’ll leave this up in case anyone winds up with the same issue and also struggles to problem solve.

After searching Quora and Stack Overflow, answers seemed to indicate that breakpoints are things people do intentionally to troubleshoot their code… so I decided to just google “breakpoint” and read the wiki and it turns out of course to be true! It’s always a great feeling to laugh at yourself after a three hour headache because you took a very inefficient route in troubleshooting a problem :sweat_smile:

Anyway, I assumed that the blue arrow pointing to that particular line of my code giving me the error was put there because there was an error… Nope! I put it there. If you double click on a line number it puts that blue arrow there… you get rid of it by right-clicking on it and selecting “Disable Breakpoint” or better yet “Delete Breakpoint.” Things are running smoothly now!

Conclusion: Don’t be like me! If you’re struggling with something like this in a new-to-you development environment or technology, google keywords in your error messages, then search stack overflow, quora, youtube, etc., then retrace your steps, then make a forum post. Or do whatever works for you in that situation. This is just what worked now. Anyways, I’m getting a bit long winded here…

Hope this proves helpful to someone else in the future!

Yeah this is a common mistake. :slight_smile: I’m glad you figured out the solution!