title: Counting score with swift
body: <p>Now, my problem is that when I am trying to count a score line if a person writes something that is not the same as "42" in a textfield (which will be the same as the label.text) they will get punished by 1 minus point. If I have written something which is not "42" it gives me 1 minus point for it but only the first time. If I do it again the scoreline will not change so I will be stuck at the -1 scoreline. </p>
  
  <p>How can i do so every time I write something which is not "42" it will give me a -1 point even if I already got a -1 score? </p>
  
  <p>(As you can see I have set the label.text to be the same as textfield.text if you are wondering)</p>
  
  <pre><code>import UIKit
  
      class ViewController: UIViewController, UITextFieldDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
  
          // MARK: PROBERTIES
          @IBOutlet weak var label: UILabel!
  
          @IBOutlet weak var textField: UITextField!
          @IBOutlet weak var scoreLabel: UILabel!
  
          @IBOutlet weak var photoImageView: UIImageView!
          @IBOutlet weak var label2: UILabel!
          @IBOutlet weak var label1: UILabel!
          let imagePicker = UIImagePickerController()
  
          override func viewDidLoad() {
              super.viewDidLoad()
  
  
              textField.delegate = self
              imagePicker.delegate = self
  
          }
  
  
          func textFieldShouldReturn(textField: UITextField) -&gt; Bool {
  
              textField.resignFirstResponder()
  
              return true
          }
          func textFieldDidEndEditing(textfield: UITextField) {
              label.text = textField.text
              var score = 0
  
  
              if textField.text != "42" {
                  score -= 1
              }
  
              // MARK: if-statements
  
              if label.text! == "42" {
                  label1.text = "You are correct"
                  self.view.backgroundColor = UIColor.greenColor()
                  score += 10
              }
  
              if label.text != "42" {
                  label1.text = "Damn, wrong"
                  self.view.backgroundColor = UIColor.redColor()
  
              }
  
              if label.text!.isEmpty {
                  label1.text = "Still waiting for an answer..."
  
              }
  
              if label.text == "happiness" {
                  label1.text = "It is not a key element in the meaning of life"
  
              }
  
              if label.text == "to be happy" {
                  label1.text = "i would rather be rich"
  
              }
  
              if label.text == "money" {
                  label1.text = "there is more in this world than money"
  
              }
  
              if label.text == "There is no meaning of life" {
                  label1.text = "There is a meaning to everything"
  
              }
  
              if label.text == "there is no meaning of life"
              {
                  label1.text = "there is a meaning to everything"
  
              }
  
              if label.text == "to be rich" {
                  label1.text = "Money does not solve every problem"
  
  
              }
  
              var scoreString = String(score)
              scoreLabel.text = "Your score is \(scoreString)"
  
  
          }
  </code></pre>