Created
January 9, 2015 13:03
-
-
Save karolkozub/0507f79cbc6765c16b43 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <objc/runtime.h> | |
#import <objc/message.h> | |
@interface A : NSObject - (void)abc; @end | |
@interface B : A @end | |
@interface C : B @end | |
@implementation A - (void)abc { NSLog(@"-[A abc]"); } @end | |
@implementation B - (void)abc { NSLog(@"-[B abc]"); } @end | |
@implementation C - (void)abc { NSLog(@"-[C abc]"); } | |
-(void)abc_A { struct objc_super sup = {self, [A class]}; objc_msgSendSuper(&sup, @selector(abc)); } | |
-(void)abc_B { struct objc_super sup = {self, [B class]}; objc_msgSendSuper(&sup, @selector(abc)); } | |
-(void)abc_C { struct objc_super sup = {self, [C class]}; objc_msgSendSuper(&sup, @selector(abc)); } | |
@end | |
int main(int argc, char *argv[]) { | |
[[C new] abc_A]; | |
[[C new] abc_B]; | |
[[C new] abc_C]; | |
} | |
// Prints out: | |
// -[A abc] | |
// -[B abc] | |
// -[C abc] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment