ios - Correct Concept for Object-Oriented Programming -
i asking question see if understanding of how object-orientation works correct. let's have abstract super class has several methods sort of implementation.
@interface superclass : uiviewcontroller - (void)methodone; // other public stuff @end
.......
@implementation superclass - (void)methodone { //some implementation } - (someobject *)objectmethod { //more implementation } @end
then if implementing subclass of that:
@interface subclass : superclass @end
.......
@implementation subclass - (void)methodone { // override method implementation code } @end
so example above, if create view controller, class of subclass, create subclass object , automatically add implementation of superclass methods? idea getting @ if when preprocessor runs, take method has not been overridden in subclass , place super class code method class it's use? in case overrode 'methodone' method super class , left 'objectmethod' method alone. mean subclass utilize new overridden 'methodone' implementation , use superclasses' 'objectmethod' implementation?
thanks bunch! let me know if need clarify something.
if redefine methodone
in subclass implementation, instances of subclass use redefined implementation. if there no redefinition subclass implementation, implementation of superclass definition. process recursively continues through higher super classes until finds definition.
if you'd modify definition in subclass, like:
-(void) methodone{ // code add before superclass's implementation called .... // call superclass's implementation [super methodone]; // code add after superclass's implementation called ... }
Comments
Post a Comment