Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
53
Task/Inheritance-Multiple/Objective-C/inheritance-multiple.m
Normal file
53
Task/Inheritance-Multiple/Objective-C/inheritance-multiple.m
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
@interface Camera : NSObject {
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation Camera
|
||||
@end
|
||||
|
||||
@interface MobilePhone : NSObject {
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation MobilePhone
|
||||
@end
|
||||
|
||||
@interface CameraPhone : NSObject {
|
||||
Camera *camera;
|
||||
MobilePhone *phone;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation CameraPhone
|
||||
|
||||
-(instancetype)init {
|
||||
if ((self = [super init])) {
|
||||
camera = [[Camera alloc] init];
|
||||
phone = [[MobilePhone alloc] init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)forwardInvocation:(NSInvocation *)anInvocation {
|
||||
SEL aSelector = [anInvocation selector];
|
||||
if ([camera respondsToSelector:aSelector])
|
||||
[anInvocation invokeWithTarget:camera];
|
||||
else if ([phone respondsToSelector:aSelector])
|
||||
[anInvocation invokeWithTarget:phone];
|
||||
else
|
||||
[self doesNotRecognizeSelector:aSelector];
|
||||
}
|
||||
|
||||
-(NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {
|
||||
return [camera methodSignatureForSelector:aSelector]
|
||||
?: [phone methodSignatureForSelector:aSelector]
|
||||
?: [super methodSignatureForSelector:aSelector];
|
||||
}
|
||||
|
||||
-(BOOL)respondsToSelector:(SEL)aSelector {
|
||||
return [camera respondsToSelector:aSelector]
|
||||
|| [phone respondsToSelector:aSelector]
|
||||
|| [super respondsToSelector:aSelector];
|
||||
}
|
||||
|
||||
@end
|
||||
Loading…
Add table
Add a link
Reference in a new issue