My storyboard is like this:

So from navigation controller , i am going to a tab controller.
My tab controller has its classed, named: MYTabBarView
In MyTabBarView.m , in its ViewDidLoad method I created the right bar button item programmatically like this:
UIBarButtonItem *homeButton = [[UIBarButtonItem alloc] initWithTitle:@"Home" style:UIBarButtonSystemItemAction target:self action:@selector(homeButtonAction)];
self.navigationItem.rightBarButtonItem=homeButton;
my question is how do I write an action for it. I mean if it was a button that was visible in the storyboard, I would “drag and dropped” it in the .h file and in the .m file I would have
the method:
Now what should I do?
- (IBAction)home:(id)sender {
....
}
Use the selector you typed when you created the button:
And if you want to pass along the sender use
@selector(homeButtonAction:)and the following method: