swift - Adding and Displaying Integers in a Label -


i'm making scoring app can keep track of score different board games or such playing. here code have far.

override  func viewdidload() {         super.viewdidload()     }      @iboutlet weak var scoretextfield: uitextfield!     @iboutlet weak var scoretotal: uilabel!       @ibaction func buttonpressed(sender: anyobject) {          if let number = int(scoretextfield.text!){         scoretotal.text = "\(number)"         }      } 

i want able type in textfield , when button pressed add both previous number , 1 in textfield , display result in label. can me please? thank you!

if let number = int(scoretextfield.text!){     let previousscoretext = scoretotal.text     if previousscoretext == nil || previousscoretext.isempty == true {         previousscoretext = "0"     }     scoretotal.text = "\(int(previousscoretext!)! + number)" } 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -