-
-
Save XueshiQiao/7323070 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
// | |
// AppDelegate.m | |
// CallSuperMethod | |
// | |
#import <objc/objc-runtime.h> | |
#import "AppDelegate.h" | |
@interface Superclass : NSObject | |
- (NSString*)a; | |
@end | |
@implementation Superclass | |
- (NSString*)a; | |
{ | |
return @"Super"; | |
} | |
@end | |
@interface Subclass : Superclass | |
- (NSString*)a; | |
@end | |
@implementation Subclass | |
- (NSString*)a; | |
{ | |
return @"Subclass"; | |
} | |
@end | |
@implementation AppDelegate | |
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification | |
{ | |
Subclass *subclass = [Subclass new]; | |
NSLog(@"[subclass a]:%@",[subclass a]); | |
struct objc_super superInfo = { | |
subclass, | |
[subclass superclass] | |
}; | |
NSLog(@"[[subclass super] a]:%@",objc_msgSendSuper(&superInfo, @selector(a))); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment