I want to connect a custom protocol delegate from a storyboard instance of a custom class.
I found this similar issue from 2014 Can not connect custom protocol delegate from storyboard in Xcode 6.1
Is there a solution for this in the future (we are in the future. It is the year 2019 and cars can drive themselves).
So I have to set up an outlet with AnyObject
@IBOutlet weak var buttonStatusDelegate: AnyObject!
which can be set in the storyboard or through code i.e.:
testButton.buttonStatusDelegate = self
and then to call the delegate I have to cast to the type using the code
if let bsd = buttonStatusDelegate as? StatefulButtonStatusChanged { bsd.stateCallback(self.status)}
So is there a better way that can support a custom button in both the storyboard and in code, or is the AnyObject solution above the only solution?