I’ve got two classes A and B. In class A i use:
@interface A : B
In class B i’ve got this line of code:
self.navigationItem.rightBarButtonItem = [UIBarButtonItem barItemWithImage:[UIImage imageNamed:@"Add-button-normal"]
highlightedImage:[UIImage imageNamed:@"Add-button-active"]
target:self
action:@selector(showPopoverUI:)];
How can i access this items in class A, i try this line of code but it doesnt work:
self.navigationItem.rightBarButtonItem = [UIBarButtonItem barItemWithImage:[UIImage imageNamed:@"Add-button-normal"]
highlightedImage:[UIImage imageNamed:@"Add-button-active"]
target:self.parentViewController
action:@selector(showPopoverUI:)];
And i got this error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[B showPopoverUI:]: unrecognized selector sent to class 0x226308'
You are targeting the parentViewController in your second example, instead you should continue to target self.