First of all I have seen that there are many questions about "unrecognized selector sent to instance" issue.
I have seen few but saw nothing about accessing a defined in category property...
I have a category on UILabel with a property.
The getter and the setter are defined.
Actually I have the same property in 2 different categories (for 2 different classes: UIButton and UILabel).
The problem is that I can access this property for UIButton but not for UILabel.
Once I try to access any method/property in UILabel(text) category it drops the "-[UILabel test]: unrecognized selector sent to instance 0x4e539f0" exception.
Both categories files are imported.
I have no idea what is the problem.
Here is some code:
// UILabel+text.h
@interface UILabel (text)
- (void)test;
@end
// UILabel+text.m
@implementation UILabel (text)
- (void)test {
NSLog(@"test");
}
@end
// UIButton+text.h
@interface UIButton (text)
- (void)test;
@end
// UIButton+text.m
@implementation UIButton (text)
- (void)test {
NSLog(@"test");// works
}
@end
// Usage (in UIViewController class) - both elements are defined in XIB
[self.button test];// works
[self.label test];// exception
Any help will be appreciated.
I don't have a clue for possible problem...
Thank you.
Michael.
Are you using a static library? If so, add all_load to Other Linker Flags.
Are you sure "UILabel+text.m" is in the target?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With