Objective c NSInvocation:虽然已设置,但无法识别选择器
我收到了这样的信息: “(null):发送到类0x3f52e824的无法识别的选择器” 我尝试过的基本代码:Objective c NSInvocation:虽然已设置,但无法识别选择器,objective-c,ios,nsinvocation,Objective C,Ios,Nsinvocation,我收到了这样的信息: “(null):发送到类0x3f52e824的无法识别的选择器” 我尝试过的基本代码: SEL sel = @selector(applyProperties:toObject:); NSInvocation* inv = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:sel]]; [inv setTarget:self]; [inv setSelector:sel
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];
我可以用这些参数自己调用(applyproperty:toObject)。。。所以我不确定我做错了什么。答案是显而易见的,而且由于阅读速度太快,很容易在文档中漏掉。参数0和1是保留的,所以我通过设置索引2和3来解决这个问题。这段代码在实例或类方法中吗?@jacob它在实例中Is
applyProperties:toObject:
实例方法?@jacob是的,它是实例方法。我可以并且有时确实调用[self-applyProperties:params toObject:theObject],就像上面的代码一样。