NSInvocation:虽然设置了无法识别的选择器

时间:2011-02-08 20:12:06

标签: objective-c ios nsinvocation

我收到了这条消息:

“(null):无法识别的选择器发送到类0x3f52e824”

我尝试过的基本代码:

SEL sel = @selector(applyProperties:toObject:);

NSInvocation* inv = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:sel]];
[inv setTarget:self];
[inv setSelector:sel];
[inv setArgument:params atIndex:0];
[inv setArgument:theObject atIndex:1];

NSOperationQueue* queue = [[NSOperationQueue alloc] init];
NSInvocationOperation* operation = [[NSInvocationOperation alloc] initWithInvocation:inv];
[queue addOperation:operation];

 [queue release];

我可以用这些参数调用(applyProperties:toObject)...所以我不确定我做错了什么。

1 个答案:

答案 0 :(得分:4)

答案很明显,很容易在文档中被错误的阅读副本错过。参数0和1是保留的,所以我通过设置索引2和3

来解决