1
votes

I created a custom UIButton like this

@interface CustomButton : UIButton {

    NSString *firstLine;
    NSString *secondLine;
}
@property (nonatomic, retain) NSString *firstLine;
@property (nonatomic, retain) NSString *secondLine;

@end

CustomButton* rightButton = [CustomButton buttonWithType:UIButtonTypeDetailDisclosure];
rightButton.secondLine=@"hello";

error message is:

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[UIButton setSecondLine:]: unrecognized selector sent to instance 0x43280e0'

What has to be done to fix this up? how should the instance variable added?

2
rightButton.secondLine = @"hello". Sorry all. That was a typo error. I will update the question now.thndrkiss

2 Answers

0
votes

Well if that is all thats in your CustomButton implementation, it seems that the String is not getting placed into the Button. How are you laying out the subviews of the button?

0
votes

Try

rightButton.secondLine = @"hello";

You should override this class method

+ (id)buttonWithType:(UIButtonType)buttonType

to return an instance of your CustomButton