0
比如我想从UIButton的覆盖:如何以正确的方式覆盖便利的构造函数?
+ (id)buttonWithType:(UIButtonType)buttonType
所以我会做:
+ (id)buttonWithType:(UIButtonType)buttonType {
UIButton *button = [UIButton buttonWithType:buttonType];
if (button != nil) {
// do own config stuff ...
}
return button;
}
是正确的方式?或者我错过了什么? (是的,我已经覆盖了数以千计的实例方法,但从来没有类方法;))