Reputation: 1725
This should be straight forward but I am having some issues with this. I have an UIView A which has a function A. I create a Selector for function A in UIView A.
SEL littleSelector = @selector(handleTapButton1);
I create UIView B and pass this selector to UIView B constructor and save it in UIView B. I set up UITapGestureRecognizer in UIView B and I assign selector from UIViewA "littleSelector" as its action. I get an exception = unrecognized selector sent to instance. I know selectors are not really function pointers but look up numbers. I also made sure that UIView A is retained.
Any ideas ?
Upvotes: 1
Views: 314
Reputation: 119041
A selector needs to be paired with an appropriate target. If you supply a selector for A and a target instance of B you will have this kind of issue. You need to set the target properly to A so the method represented by the selector is called on the right class instance.
Upvotes: 1