I want to accomplish touching a UIButton and having code run in a different class than the owner.
I realize I can do a touchUpInside to the button’s owner (ClassA) and then call the method inside ClassB that I want called, but is there any way to expedite this?
ideas:
-
have
ClassBbe the delegate for theClassA->UIButton -
set the
touchUpInsidecall in programming to used the function insideClassB
I’m not sure how to accomplish either of these ideas 🙁 Input is mas appreciated!
One option is to set the button up using
but this is a bit dangerous because
targetis not retained so you could send the message to a deallocated object.You could instead set up a protocol
Then in your implementation
As the method defined in the protocol was not optional I could have instead done a check for
(self.delegate)to make sure it is set instead ofrespondsToSelector.