Im trying to make it so that every single UIControl
in my application (UIButton
, UISlider
, etc) all have special extra properties that I add to them.
I tried to accomplish this by creating a UIControl
Category and importing it where needed but I have issues.
Here is my code.
My setSpecialproperty
method gets called but it seems to be getting called in an infinite loop until the app crashes.
Can you tell me what Im doing wrong or suggest a smarter way to add a property to all of my UIControls
?
@interface UIControl (MyControl)
{
}
@property(nonatomic,strong) MySpecialProperty *specialproperty;
-(void)setSpecialproperty:(MySpecialProperty*)param;
@end
////////
#import "UIControl+MyControl.h"
@implementation UIControl (MyControl)
-(void)setSpecialproperty:(MySpecialProperty*)param
{
self.specialproperty=param;
}
///////////////
#import "UIControl+MyControl.h"
@implementation ViewController
UIButton *abutton=[UIButton buttonWithType:UIButtonTypeCustom];
MySpecialProperty *prop=[MySpecialProperty alloc]init];
[abutton setSpecialproperty:prop];