0

So I just started to learn how to code. I was making an app that lets you guess a number from 0-5 which the phone has randomly generated. When I run the app I get an error saying "thread 1: Breakpoint 1.4"Check Image Also some additional information which might be helpful:

I was getting an error before which stated "Cannot assign a value of type '(UInt32)' to a value of type 'String?'"

@IBOutlet weak var outputLbl: UILabel!

@IBOutlet weak var guessTxt: UITextField!

@IBAction func guessButton(_ sender: Any) {

    let random = String(arc4random_uniform(6))

    if guessTxt.text == random {

      outputLbl.text = "You guessed the right number"

    } else {

        outputLbl.text = "You guessed the wrong number"

    }

}
AriGold
  • 85
  • 1
  • 2
  • 4
  • if guessTxt.text == random // error is because you are comparing two different types of variables i.e int and string – Anil Kumar May 14 '17 at 17:08
  • Do you need help with just the 'thread 1: breakpoint 1.4' error or do you still get the 'cannot assign a value' error? In the image of the code (btw, you really shouldn't post an image of code, just paste the code) that's not an error, that's a breakpoint. Did you accidentally set one on that line? – Jim May 14 '17 at 23:39
  • @Jim I don't know if i accidentally put the breakpoint there but when i run the simulator the simulator stops and it shows thread 1: breakpoint 1.4 – AriGold May 15 '17 at 05:48
  • @Jim Anyway I could remove the breakpoint? – AriGold May 15 '17 at 05:49
  • Thanks guys I understood the breakpoint and was able to solve my problem. – AriGold May 15 '17 at 05:58
  • Glad you resolved the problem, @Aryan. Breakspoints are one of the most important tools you have so I recommend reading up on them before you do anything else. Here's a good, short intro to them: https://medium.com/yay-its-erica/xcode-debugging-with-breakpoints-for-beginners-5b0d0a39d711 – Jim May 15 '17 at 13:08

0 Answers0