Skip to content

Instantly share code, notes, and snippets.

@wess
Created September 29, 2012 02:52
Show Gist options
  • Save wess/3802994 to your computer and use it in GitHub Desktop.
Save wess/3802994 to your computer and use it in GitHub Desktop.
objc shit
@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