I\'m making an app, and I have a class with quite a lot properties and I was wondering if it was possible to give them a default value. Because if I make an init method, it\'s a
Yes, you can override getter in case to set default value before property was inited.
For example, define property in .h file:
@interface MySegmentedControl : UISegmentedControl
@property (assign, nonatomic) CGFloat systemFontOfSize;
@end
and override getter and set default value under implementation in .m file:
@implementation MySegmentedControl
-(CGFloat) systemFontOfSize
{
return _systemFontOfSize ? _systemFontOfSize : 17.0f;
}
@end