How to fire the action of a uibarbuttonitem programatically?

Posted by Aruna Herath on Stack Overflow See other posts from Stack Overflow or by Aruna Herath
Published on 2012-06-28T09:14:50Z Indexed on 2012/06/28 9:15 UTC
Read the original article Hit count: 440

Filed under:
|
|

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 .

© Stack Overflow or respective owner

Related posts about ios

Related posts about action