title: How can I run code after the return statement in a function in Swift?
body: <p>Consider the following code:</p>
  
  <pre><code>func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -&gt; Bool {
      let validator:NSPredicate = NSPredicate(format:"SELF MATCHES %@","[A-Za-z0-9- ]+")
      if(validator.evaluateWithObject(string) || string == "" /* i.e. backspace */) {
          self.process(textField)
          return true
      }
      else {
          return false
      }
  }
  </code></pre>
  
  <p>I want to actually run self.process(textField) AFTER the return statement, because before it, the text in the textField has not actually changed yet. This led me to wonder, why can't I just execute some code <em>after</em> the return statement? Why do functions always stop when the return statement happens? </p>
  
  <p>I realize that's traditionally what return <em>means</em>, but is there an alternative? Like, is there a way to return a value from a function and then still keep going?</p>
  
  <p>On the one hand this seems like a stupid question, but on the other hand, I feel like I can't be the first person to ever want to do this. It would be good enough if I could fire off something to run on the next cycle of the run loop, so maybe there's something in GCD that would help me.</p>