I have a custom button class:
CustomButton.h file:
@interface CustomButton : UIButton
@property (nonatomic, retain) NSString* info;
@end
CustomButton.m file:
#import "CustomButton.h"
@implementation CustomButton
@synthesize info;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
@end
In my main view controller:
CustomButton* btn = [CustomButton buttonWithType:UIButtonTypeDetailDisclosure];
[btn setInfo:@"foobar"];
NSLog(@"%@", [btn info]);
[self.view addSubview:btn];
If it's just a simple button ([CustomButton new]
) I don't get any error. But if I choose buttonWithType:UIButtonTypeDetailDisclosure
I get this error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[UIButton setInfo:]: unrecognized selector sent to instance 0x753c8c0'
Why is this happening?