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!