I have seen this for a normal UIButton:
NSArray *actions = [viewController.addButton actionsForTarget:viewController forControlEvent:UIControlEventTouchUpInside];
XCTAssertTrue([actions containsObject:@”addNumbers:”], @””);
But now I want to do same thing for a rightBarButtonItem! I have tested this button exist on the VC but there is no interface actionForTargets!
I tried this also but it did not work:
NSArray *actions = [self.navigationItem.rightBarButtonItem actionsForTarget:self forControlEvent:UIControlEventTouchUpInside];
or
NSArray *actions = [[self.navigationItem.rightBarButtonItem target] actionsForTarget:self forControlEvent:UIControlEventTouchUpInside];
Non of them works. Anyone has written test code for a UIBarButton to check if button is connected to correct IBAction?