The gist of the article is that we can omit the verbose #selector syntax by adding a convenience property:

private extension Selector {
static let buttonTapped =
button.addTarget(self, action: .buttonTapped,
forControlEvents: .TouchUpInside)

I’d make that not private but internal and group these in a struct to separate them from other Selector stuff:

extension Selector {
// One for each view module ...
struct Banana {
static let changeSizeTapped =

struct Potato {
static let peelSelected =

// ...

button.addTarget(self, action: .Potato.peelSelected,
forControlEvents: .TouchUpInside)

Great tip!

via Worklog of Christian Tietze

Show your support

Clapping shows how much you appreciated Christian Tietze’s story.