How to fire the action of a uibarbuttonitem programatically?
- by Aruna Herath
I have created an uibarbuttonitem dynamically and it works properly. I want to fire that uibarbutton item action(click) programatically for unit testing.
Even though the code work properly when I log the action of the bar button item in the application code (not on testing code) it gives null. The code I have used is given below.
NSLog(@"%@",NSStringFromSelector(barButton.action));
In the testing code I have created a bar button called logout and assign barbutton to that.To click the bar button item programatically I followed the following code.
[logout.target performSelector:logout.action];
But it didn't work . I logged the action of logout button and it also gives null.
NSLog(@"%@",logout.action);
I want to know how to programatically click a uibarbutton item which created dynamically .