Created
September 29, 2012 02:52
-
-
Save wess/3802994 to your computer and use it in GitHub Desktop.
objc shit
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
@protocol ClassADelegate; | |
@interface ClassA : NSObject | |
@property (strong, nonatomic) id<ClassADelegate>delegate; | |
- (void)letShitHappen; | |
@end | |
@protocol ClassADelegate <NSObject> | |
- (void)doSomeShit; | |
@end | |
@implementation ClassA | |
- (void)init | |
{ | |
self = [super init]; | |
if(self) | |
{ | |
} | |
return self; | |
} | |
- (void)letShitHappen | |
{ | |
[self.delegate doSomeShit]; | |
} | |
@end | |
@interface ClassB : NSObject<ClassADelegate> | |
@property (strong, nonatomic) ClassA *shit; | |
@end | |
@implementation ClassB | |
- (id)init | |
{ | |
self = [super init]; | |
if(self) | |
{ | |
self.shit = [[ClassA alloc] init]; | |
self.shit.delegate = self; | |
} | |
return; | |
} | |
- (void)ahhShit | |
{ | |
[self.shit letShitHappen]; | |
} | |
- (void)doSomeShit | |
{ | |
NSLog(@"OH SHIT"); | |
} | |
@end | |
@interface ClassC : ClassB | |
@end | |
@implementation ClassC | |
@end | |
/** | |
ClassC *c = [[ClassC alloc] init]; | |
[c ahhShit]; | |
^^^^^ | |
Why doesn't ClassA's delegate trigger, since ClassC inherits from ClassB? | |
**/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment