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 trialArjun Jain
2,047 PointsThread Break issue
I'm working on the FunFacts program and tried to edit it so that it would not repeat facts. When I try running the app, I just see the title screen, and in my code there is a "Thread Breakpoint" that shows up.
Some of the things I added to my FactBook struct:
var countCheck = [-1]
mutating func randomFact() -> String {
var arrayCount = UInt32(factsArray.count)
var randomNumber = Int(arc4random_uniform(arrayCount))
while contains(countCheck, randomNumber)
{
randomNumber = Int(arc4random_uniform(arrayCount))
}
countCheck.append(randomNumber)
return factsArray[randomNumber]
}
func gameOver() -> Bool {
return ((countCheck.count - 1) == factsArray.count)
}
My ViewController file-- note I changed "let factBook = FactBook()" to "var factBook = FactBook()" because it was throwing errors due to the mutating function I added to the struct.
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var funFactLabel: UILabel!
var factBook = FactBook()
override func viewDidLoad() {
super.viewDidLoad()
funFactLabel.text = factBook.randomFact()
// 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() {
funFactLabel.text = factBook.randomFact()
}
}
2 Answers
Stone Preston
42,016 Pointsits possible you accidently set a breakpoint. press command + y to disable all breakpoints and try running again. If you would like to remove the breakpoint completely press command + 7 and then right click on the breakpoint in the navigator and delete it. if that doesnt work, can you post the stuff that comes up in your console when the app breaks
Chris Hedstrom
3,024 PointsThank you for posting this solution, helped me too. I had exactly the same break point issue and it was driving me nuts.
Arjun Jain
2,047 PointsArjun Jain
2,047 PointsSweet! That is exactly what happened. Thank you!
Otto Awqatty
4,208 PointsOtto Awqatty
4,208 PointsI had the same issue, thanks man!
Stone Preston
42,016 PointsStone Preston
42,016 Pointsglad it helped
Greg Mazzeo
2,409 PointsGreg Mazzeo
2,409 PointsSame thing here! Thanks for your help, Stone. I don't know how I enabled or set a breakpoint :-S
Juan Munoz
2,146 PointsJuan Munoz
2,146 PointsTHANK YOU!!!