Swift programmatically create function for button with a closure
<p>In Swift you can create a function for a button like this:</p>

<pre><code>button.addTarget(self, action: #selector(buttonAction), forControlEvents: .TouchUpInside)
</code></pre>

<p>However is there a way I can do something like this:</p>

<pre><code>button.whenButtonIsClicked({Insert code here})
</code></pre>

<p>That way I do not even have too declare an explicit function for the button. I know I can use button tags but I would prefer to do this instead.</p>