I'm creating a fitness app in Xcode where different activities are worth different points and the user has a total points on the homepage. I am trying to convert the UILabel (which I have specified the points for each challenge) to an Integer so I can calculate the users total points when they have chosen that challenge.
I believe that I need to do this using Swift and have connected the UILabel to an outlet and given the calculating button an action, however I cannot figure out how to get an Int Value from the UILabel in order to do the calculation.
Please can anyone help with how to do this, or if you can think of a better way of doing so.
Thanks in advance
I've got this, no errors but nothing happens when button is pressed. I'm aiming to add the new points to the current points but trying to get this part working first.
@IBAction func Calculate(_ sender: Any) {
if let NewPointsText = NewPoints.text,
let NewPointsValue = Int(NewPointsText){
print(NewPointsValue)
} else{
print("Not Worked")
}
if let CurrentPointsText = CurrentPoints.text,
let CurrentPointsValue = Int(CurrentPointsText){
print(CurrentPointsValue)
}else{
print("Current Points Not Worked")
}
}
}