子类UIButton添加属性
我想子类UIButton添加一些我需要的属性(不是方法...只有属性)。
这是我的子类的代码:
//.h-----------------------@interface MyButton : UIButton{
MyPropertyType *property;}@property (nonatomic,retain) MyPropertyType *property;@end//.m--------------------------@implementation MyButton@synthesize property;@end在这里我如何使用该类:
MyButton *btn = ((MytButton *)[MyButton buttonWithType:UIButtonTypeRoundedRect]);btn.property = SomeDataForTheProperty;
从哪里获得此错误:
-[UIRoundedRectButton setProperty:]: unrecognized selector sent to instance 0x593e920
因此,从ButtonWithType我获得一个UIRoundedRectButton,(Mybutton *)不能施展它...我需要做什么来获得一个MyButton对象?是-init唯一的解决方案?
谢谢!
眼眸繁星