セレクターと引数を出力するだけで、プロキシオブジェクトに送信されたメッセージをインターセプトしたいと思います。プロキシがそれらを実装しておらず、ターゲットオブジェクトがない場合でも。助けてください。私はいくつかのオプションとAppleドキュメントを見てきましたが、それらはあなたがすでにターゲットオブジェクトを知っていることを前提としています。私はこれをメモリの問題なしにきれいにやりたいと思っています。
@implementation MyProxy
-(void)forwardInvocation:(NSInvocation*)anInvocation
{
// at this point I would
//like to fetch the arguments and put on an array
NSMutableArray *myArgs = .....;
NSLog(@"Invoking selector %@", theSelector);
NSLog (myArgs); // this should print me the list of arguments to the method
}
@end
// e.g
MyProxy *proxy = [[MyProxy alloc] init];
[proxy SendMeAnyThing: @"hello"]; // this should print me arguments
or [proxy add: 12 to: 89 sub: 89]; // should print the arguments
どうもどうも