title: Inline Block/Function with Selector in Swift
body: <p>Is there a native language feature for inline selectors in Swift? If not, is there an elegant pattern for this? </p>
  
  <p>For example, an NSTimer using a Selector. This is a way you can do it without any inline function or block:</p>
  
  <pre><code>var timer = NSTimer.scheduledTimerWithTimeInterval(2, target: self, selector: "update", userInfo: nil, repeats: false)
  
  @objc func update() {
      print("timer up")
  }
  </code></pre>
  
  <p>I would rather have something like this. <em>This is a concept and does not compile.</em></p>
  
  <pre><code>var timer = NSTimer.scheduledTimerWithTimeInterval(2,
          target: self,
          selector: { println("timer up") }, // What can I do here?
          userInfo: nil,
          repeats: false)
  </code></pre>
  
  <p>This is similar to this <a href="https://stackoverflow.com/questions/4581782/can-i-pass-a-block-as-a-selector-with-objective-c">question</a> asked about inline selectors in Objective C.</p>