title: How do I store data (user input from a textfield)
body: <p>I am using Swift and I want to know how I can store user input as a variable (it’s a double).</p>
  
  <p>I'm still in the learning states so I have been watching youtube tutorials on the situation but nothing helped.</p>
  
  <p>My code:</p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
  
      @IBOutlet weak var userInput: UITextField!
      override func viewDidLoad() {
          userInput.delegate = self
      }
  
      @IBAction func Increment(_ sender: UIButton) {
          var inc = 0
          userInput = userInput + inc
      }
  
      @IBAction func Decrement(_ sender: UIButton) {
  
      }
      override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
          userInput.resignFirstResponder()
  
      }
  
  }
  
  extension ViewController: UITextFieldDelegate{
      func textFieldShouldReturn(_ textField: UITextField) -&gt; Bool {
          textField.resignFirstResponder()
  
          return true
      }
  
  }
  </code></pre>
  
  <p>The user will be able to enter a number and increment or decrement the number by a certain input value.</p>