<div dir="ltr">It feels a lot more Swift-like to me to allow a Selector argument to have the option of being a closure.<div><br></div><div>For example, instead of:</div><div><br></div><div><pre class="default prettyprint prettyprinted" style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span class="typ" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">UIBarButtonItem</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">title</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">:</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="str" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"Press"</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> style</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">:</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span class="typ" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Done</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> target</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">:</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="kwd" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">self</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> action</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">:</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="str" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"functionToCall"</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
func functionToCall</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">()</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">{</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="com" style="margin:0px;padding:0px;border:0px;color:rgb(128,128,128)">// Do something</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">}</span></code></pre>We should be able to do:</div><div><br></div><div><pre class="default prettyprint prettyprinted" style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span class="typ" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">UIBarButtonItem</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">title</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">:</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="str" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"Press"</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> style</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">:</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span class="typ" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Done</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> target</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">:</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="kwd" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">self</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> action</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">:</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">{</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="com" style="margin:0px;padding:0px;border:0px;color:rgb(128,128,128)">// Do Something</span><span class="pln" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="pun" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">})</span></code></pre>For simple tasks it would be a lot neater, and indeed faster to code this way.</div><div><br></div><div>Thanks,</div><div><br></div><div>Chris</div></div>