Swift – Adding closure to NSMenuItem

Closures are self-contained blocks of functionality that can be passed around and used in your code. Closures in Swift are similar to blocks in C and Objective-C and to lambdas in other programming languages…
[Apple – The Swift Programming Language]

Apples implementation of the class NSMenutItem does not support the use of closures. But fortunately adding the power of closures is very simple by subclassing NSMenutItem:

Using the new class MyMenuItem is that easy: