Objective-C에서의 메세지 포워딩 순서
resolveInstanceMethod - nono
forwardingTargetForSelector - nono
methodSignatureForSelector - nono
forwardInvocation - nono
doesNotRecognizeSelector - nono
위의 순서로 호출이 되므로 필요한 곳에서 프록시등이 호출되도록 해야함.
@interface TextObject : NSObject
@end
@implementation TextObject
+ (BOOL)resolveInstanceMethod:(SEL)sel
{
NSLog(@"resolveInstanceMethod - %@", NSStringFromSelector(sel));
return [super resolveInstanceMethod:sel];
}
+ (BOOL)resolveClassMethod:(SEL)sel
{
NSLog(@"resolveClassMethod - %@", NSStringFromSelector(sel));
return [super resolveClassMethod:sel];
}
- (id)forwardingTargetForSelector:(SEL)sel
{
NSLog(@"forwardingTargetForSelector - %@", NSStringFromSelector(sel));
return [super forwardingTargetForSelector:sel];
}
- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel
{
NSLog(@"methodSignatureForSelector - %@", NSStringFromSelector(sel));
NSString *types = @"@@:";
return [NSMethodSignature signatureWithObjCTypes:[types UTF8String]];
}
-(void)forwardInvocation:(NSInvocation *)invocation;
{
SEL sel = [invocation selector];
NSLog(@"forwardInvocation - %@", NSStringFromSelector(sel));
return [super forwardInvocation:invocation];
}
- (void)doesNotRecognizeSelector:(SEL)sel
{
NSLog(@"doesNotRecognizeSelector - %@", NSStringFromSelector(sel));
[super doesNotRecognizeSelector:sel];
}
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
TextObject *to = [TextObject new];
[to performSelector:NSSelectorFromString(@"nono")];
return YES;
}
@end