CCSprite
is the super class of superClass
superClass
is the super class of subClass
there is two ways of using method in super class, for example
@interface superClass : CCSprite
- (void)doSomething;
- (id)somethingElse;
@end
@implement superClass
- (void)doSomething {
NSLog( @"do something in super class" );
}
- (id)somethingElse {
return @"something else in super class";
}
@end
@interface subClass : superClass
- (void)doSomethingTwice;
@end
@implement subClass
- (void)doSomethingTwice {
[self doSomething];
[self doSomething];
}
- (id)somethingElse {
id fromSuper = [super somethingElse];
return @"something else in sub class";
}
@end
subClass sub = [[subClass alloc] init];
[sub doSomethingTwice]; // this will call `doSomething` implemented is superClass twice
NSLog([sub somethingElse]); // this will call `somethingElse` in super class but return "something else in sub class" because it override it
basically you can just call the method implemented in super class on instance of sub class
and you can override the method in sub class to do something different and/or using [super methodName]
to call the method implementation in super class