How to overwrite a convenience constructor the proper way?
Posted
by mystify
on Stack Overflow
See other posts from Stack Overflow
or by mystify
Published on 2010-05-31T10:15:28Z
Indexed on
2010/05/31
10:32 UTC
Read the original article
Hit count: 187
iphone
For example I want to overwrite from UIButton:
+ (id)buttonWithType:(UIButtonType)buttonType
So I would do:
+ (id)buttonWithType:(UIButtonType)buttonType {
UIButton *button = [UIButton buttonWithType:buttonType];
if (button != nil) {
// do own config stuff ...
}
return button;
}
is that the right way? Or did I miss something? (yeah, I have been overwriting thousands of instance methods, but never class methods ;) )
© Stack Overflow or respective owner