Add number to number in Label

i want my app to do this: when a button is pushed, it will add the specified number and the number that is in the label then show the total of the numbers in the label. Please help!
Answered by Claude31 in 645326022
Pretty straightforward.

Read label 1 and convert to Int of Float, whatever it is.
Add the new number to it
Write to label.

Code Block
@IBOutlet weak var label : UILabel!
// In the IBAction of the button
var value = Int(label.text!) ?? 0 // Get the label value content, if an Int is expected
value += specifiedValue // add the specified value
label.text = "\(value)"


Accepted Answer
Pretty straightforward.

Read label 1 and convert to Int of Float, whatever it is.
Add the new number to it
Write to label.

Code Block
@IBOutlet weak var label : UILabel!
// In the IBAction of the button
var value = Int(label.text!) ?? 0 // Get the label value content, if an Int is expected
value += specifiedValue // add the specified value
label.text = "\(value)"


Thanks! I will try it.
It worked thank you!
Add number to number in Label
 
 
Q