[swift-evolution] Allow Selectors to be used as Closures

Chris Byatt byatt.chris at gmail.com
Fri Dec 4 12:49:36 CST 2015


It feels a lot more Swift-like to me to allow a Selector argument to have
the option of being a closure.

For example, instead of:

UIBarButtonItem(title: "Press", style: .Done, target: self, action:
"functionToCall")

func functionToCall() {
    // Do something}

We should be able to do:

UIBarButtonItem(title: "Press", style: .Done, target: self, action: {
    // Do Something})

For simple tasks it would be a lot neater, and indeed faster to code this
way.

Thanks,

Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151204/44c8c0bf/attachment.html>


More information about the swift-evolution mailing list