Right now I have two labels. I would like “winningLabel” to print the games current score and “hhighscore” to save the games highest score. Right now I have a pitcure of what the code will present pic. The smaller of the two labels is hhighscore. I would just like hhighscore to save the games highest score. The score is defined by totalTime. Picture
import UIKit
class winViewController: UIViewController {
@IBOutlet var score2: UILabel!
@IBOutlet var winningLabel: UILabel!
var highScore : Double = 0
var score : Double = 0
@IBOutlet var hhighscore: UILabel!
public var LebelText: String?
public var LebelText2: String?
public var LebelText3: String?
public var LebelText4: String?
override func viewDidLoad() {
super.viewDidLoad()
timeCalculation()
}
func timeCalculation(){
guard let unwrapedText = self.LebelText2 else {
return
}
guard let unwrapedText2 = self.LebelText else {
return
}
guard let unwrapedText3 = self.LebelText3 else {
return
}
guard let unwrapedText4 = self.LebelText4 else {
return
}
if let myInt = Double(unwrapedText), let myInt2 = Double(unwrapedText2), let myInt3 = Double(unwrapedText3), let myInt4 = Double(unwrapedText4)
{
let totalTime = myInt + myInt2 + myInt3 + myInt4
self.winningLabel.text = "You won"+"\n"+"Reaction time :" + String(totalTime) + " Seconds"
hhighscore.text = String(totalTime)
}}}