objective c - Call precedence for method overridden in category and again in subclass -
i'm working on project in objective-c , i'm facing situation.
let's have class named foo
. implement category class named foo+bar
, override foo
's method foomethod:
.
then create subclass foo
, named baz
, override same foomethod:
in class.
- when use method
foomethod:
onbaz
object, implementation called? 1 insidefoo+bar
or 1 insidebaz
? - how objective-c handle situation , why?
i'm open explanation and/or documentation.
behaviour if override method in category explicitly undefined. please don't:
if name of method declared in category same method in original class, or method in category on same class (or superclass), behavior undefined method implementation used @ runtime.
if overriding method defined once in category of superclass of course subclass implementation called.
but here override method defined twice in superclass. behaviour undefined, because override undefined implementation. if worked, bad code anyway.
really, please don't this.
Comments
Post a Comment