Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restrict the access of property in the UIbutton in iPhone?

I want to restrict some property from the exisiting class of the components.

Here is the sample code,

UIButton *customBtn;
property (nonatomic, strong) UIButton *customBtn;
@synthesize customBtn;

this my implementation,

customBtn= [UIButton buttonWithType:UIButtonTypeCustom];
 customBtn= setImage:[UIImage imageNamed"radio_button_noraml.png"] forState:UIControlStateNormal];
 customBtn= setImage:[UIImage imageNamed"radio_button_acitve.png"] forState:UIControlStateSelected];
 customBtn = CGRectMake(5, 30, 20, 20); notsupport = [[UILabel alloc]initWithFrame:CGRectMake(25, 30, 290, 20)];
 [customBtn addTargetelf actionselector(MyAction:) forControlEvents:UIControlEventTouchUpInside];
 [self.view addSubview:customBtn];

In my view controller, i could access all the property in the UIbutton using the customBtn.

myClass.customBtn.backGroundcolor = [UIColor blackColor];

But i want to restrict the access of the button properties,For eg.i want to access the propertybackground color and alpha value, rest of the property i don't want to access.

so please help me out.

Thanks!

like image 411
Pugalmuni Avatar asked Nov 26 '25 19:11

Pugalmuni


1 Answers

In objective-c all methods are public, and property are nothing but setter and getter (methods).
So you can't restrict existing methods/properties.
And even if you subclass it you can only override it.
There you can add an NSAssert if anyone uses that method.

like image 184
Inder Kumar Rathore Avatar answered Nov 28 '25 08:11

Inder Kumar Rathore