I have a a xib with a toolbar and on that I have 2 buttons all made in IB.
I can connect my outlets to the buttons but when I click them the method isn’t triggered?
Why is that?
In my header file I have this:
@property (nonatomic, retain) IBOutlet UIBarButtonItem *cancelEntry;
@property (nonatomic, retain) IBOutlet UIBarButtonItem *saveEntry;
-(IBAction) cancelEntry:(id) sender;
-(IBAction) saveEntry:(id) sender;
In my .m file I got this:
-(IBAction) cancelEntry:(id) sender {
NSLog(@"cancel");
}
-(IBAction) saveEntry:(id) sender {
NSLog(@"save");
}
All compiles as it should but no nothing in the log when clicking the buttons.
What should I do to get it to work?
Sounds like you connected your outlets to the buttons, but didn’t connect the buttons to the actions.
UIBarButtonItemin Interface Builder.Instead of using
(id)for your IBActions, you should probably use(UIBarButtonItem *). That’ll prevent you from connecting a different object type to those IBActions.