Objective-C multiple inheritance -
i have 2 classes 1 includes methoda , other include methodb. in new class need override methods methoda , methodb. how achieve multiple inheritance in objective c? little bit confused syntax.
objective-c doesn't support multiple inheritance, , don't need it. use composition:
@interface classa : nsobject { } -(void)methoda; @end @interface classb : nsobject { } -(void)methodb; @end @interface myclass : nsobject { classa *a; classb *b; } -(id)initwitha:(classa *)ana b:(classb *)ab; -(void)methoda; -(void)methodb; @end
now need invoke method on relevant ivar. it's more code, there isn't multiple inheritance language feature in objective-c.
Comments
Post a Comment