Does iOS allow developer define a private IBOutlet. For example, there are several buttons in a viewController, and I want to do something with these buttons both in Interface builder and code. However I do not want other class access these buttons. Can I define some “private” IBOutlets for this buttons
example code:
@interface myViewController : UIViewController<
{
@private:
UIButton *o_Button1;
UIButton *o_Button2;
}
//Can I have these outlets as private???
@property (nonatomic, retain) IBOutlet UIButton *Button1;
@property (nonatomic, retain) IBOutlet UIButton *Button2;
@end
===============================================================
Just get one solution. Wish it will help you.
Combine Abizern and JustSid ideas together, I have a solution like this.
in .h file
@interface myViewController : UIViewController
{
@private
IBOutlet UIButton *Button1;
IBOutlet UIButton *Button2;
}
@end
and in .m file
@interface MyViewController ()
@property (nonatomic, retain) UIButton *Button1;
@property (nonatomic, retain) UIButton *Button2;
@end
...
@synthesize Button1, Button2;
Thanks for help from Abizern and JustSid
Add the properties in a category at the top of the .m file:
In fact, this is how you can set up a property as readonly in the .h file and redeclare it as a readwrite property in the .m file – so you can have private setters.