NSInvocationを使用して動的な呼び出しを行っています。
NSInvocation *lNSInvocation = [NSInvocation invocationWithMethodSignature: [lListener methodSignatureForSelector:lSelector]];
[lNSInvocation setTarget:lListener];
[lNSInvocation setSelector:lSelector];
// Note: Indexes 0 and 1 correspond to the implicit arguments self and _cmd, which are set using setTarget and setSelector.
[lNSInvocation setArgument:object atIndex:2];
[lNSInvocation setArgument:object2 atIndex:3];
[lNSInvocation setArgument:object3 atIndex:4];
[lNSInvocation invoke];
デバッガーでは、3つのオブジェクト変数すべてが3つの異なるNSCFString*を正しく指します。呼び出しが行われ、反対側で正しいメソッドに到達します。
- (void)login:(NSString*)username password:(NSString*)password host:(NSString*)host
ただし、デバッガーでは、そのパラメーターに「変数はCFStringではありません」というエラーが表示されます。さらに悪いことに; 3つの変数はすべて、同じメモリ位置を指します。
どうすればいいの?