I am trying to assign a delegate's method to a UIButton using addTarget:action:forControlEvents:. Everything compiles without warnings, the IBOutlet is connected to the button in Interface Bulder (XCode 4). If I moves the delegate's method to the controller, it works fine. (All code worked fine, but I refactored to use a delegate, it's my first try with delegates and protocols.)
(added) The protocol declaration, placed before @interface in the .h:
@protocol MMGLVDelegate<NSObject>
-(void)receiveQuitRequest:(id)sender;
@end
In the controller interface, these properties:
@property (nonatomic, assign) id<TheDelegateProtocol> delegate;
@property (nonatomic, retain) IBOutlet UIButton *quitBtn;
In the controller implementation:
-(void)setDelegate:(id<MMGLVDelegate>)delegate {
DLog(@"MMGLVSegmented setDelegate: Entered");
_delegate = delegate;
[self.quitBtn addTarget:self.delegate action:@selector(receiveQuitRequest:)
forControlEvents:UIControlEventTouchUpInside];
}
Any help appreciated. Changing target to any of self.delegate, _delegate, or delegate doesn't change app behavior.
What I'm hoping to do is not have to declare a class receiveQuitRequest: that then passes off to the delegate, I'd rather go straight to the delegate from the control.