I've created a custom view which inherits from NSView. My goal is to notify my NSWindowControl which is associated with the window that contains the custom view, when the user click the the custom view.
I would like to implement this using the Action - Target pattern , just like a NSButton does. So that I will be able connect the custom view with an action in the window controller using the Interface Builder.
Add the following to your custom view header file:
Synthesize the getter/setter in the custom view implementation file (this is actually optional with recent versions of Xcode/clang):
and to call the target/action within your code:
Note that using
performSelector:withObject:afterDelay
decouples the call from your view code and makes it run the next time the runloop is processed.