Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.51 KB | None | 0 0
  1.  
  2. import UIKit
  3.  
  4. class ViewController: UIViewController {
  5.    
  6.     @IBOutlet weak var display: UILabel?
  7.     var userIsTyping = false
  8.  
  9.     @IBAction func touchDigit(_ sender: UIButton) {
  10.         let digit = sender.currentTitle!
  11.         if userIsTyping {
  12.             let textCurrentInDisplay = display!.text! // will not be executed warning
  13.             display!.text = textCurrentInDisplay + digit
  14.         }
  15.         else {
  16.            display!.text = digit
  17.             userIsTyping = true;
  18.         }
  19.     }
  20.  
  21.  
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement