Extending UIKit Controls Through Associated Objects
Extensions are great for extending classes but unfortunately, they cannot contain stored properties. Luckily, there is a work around using Associated Objects. Below, I have used associated objects to add a callback property to a UISegmented control extension making it easier to get the selected index.

The usage of the new extension is shown below:

Enjoy!