NSIncation:尽管已设置,但仍无法识别选择器
我收到此消息:
“(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)...所以我不确定什么我做错了。
I'm getting this message:
"(null): unrecognized selector sent to class 0x3f52e824"
The basic code I've tried:
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];
I can call (applyProperties:toObject) by itself with these arguments... so I'm not sure what I'm doing wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案是显而易见的,并且由于阅读速度太快而很容易在文档中错过。参数 0 和 1 被保留,所以我通过设置索引 2 和 3 来解决
The answer is obvious, and was easy to miss in the documentation by vice of reading too quickly. Arguments 0 and 1 are reserved, so I solved by setting to indexes 2 and 3