I am trying to reduce ceremony and out of academic curiosity I want to know how to do the following without the IBAction method defined in the .m file to use a closure whenever an Interface Builder wired action occurs such as a button press. You could say that I want to imply the cancelButtonPress method below instead of having to define it. A UIViewController subclass or some magic stored in a category would be quite acceptable.
@interface MyViewController : UIViewController
{
void(^doOnCancel)(void);
}
@property (nonatomic, copy) void(^doOnCancel)(void);
- (IBAction)cancelButtonPress:(id)sender;//I want this gone!
@end
I tried changing void
to IBAction
in the property and variable with no luck.
Edit: Alternative patterns that also reduce repetition in using closures for actions would also be useful.
The bounty is for a good pattern that will allow for closures to be arbitrarily used to service actions defined in IB in a way that could be used to reduce ceremony. The "can't do it" comments so far might or might not be correct.