Created
May 2, 2013 18:09
-
-
Save PsychoH13/5504107 to your computer and use it in GitHub Desktop.
Message to super
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 <objc/runtime.h> | |
#import <Foundation/Foundation.h> | |
@interface Superclass1 : NSObject | |
- (void)testMethod; | |
@end | |
@interface Superclass2 : NSObject | |
- (void)testMethod; | |
@end | |
@interface Subclass : Superclass1 | |
@end | |
int main(int argc, const char * argv[]) | |
{ | |
@autoreleasepool | |
{ | |
Subclass *obj = [[Subclass alloc] init]; | |
[obj testMethod]; | |
class_setSuperclass([Subclass class], [Superclass2 class]); | |
[obj testMethod]; | |
} | |
return 0; | |
} | |
@implementation Superclass1 | |
- (void)testMethod; | |
{ | |
NSLog(@"Superclass1"); | |
} | |
@end | |
@implementation Superclass2 | |
- (void)testMethod; | |
{ | |
NSLog(@"Superclass2"); | |
} | |
@end | |
@implementation Subclass | |
- (void)testMethod; | |
{ | |
[super testMethod]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment