【发布时间】:2011-03-12 03:28:42
【问题描述】:
我收到了这条消息:
"(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)...所以我不确定我做错了什么。
【问题讨论】:
-
这段代码是在实例方法还是类方法中?
-
@jacob 它在一个实例中
-
applyProperties:toObject:是实例方法吗? -
@jacob 是的,它是一个实例方法。我可以并且有时确实调用 [self applyProperties:params toObject:theObject],就像上面的代码一样。
标签: objective-c ios nsinvocation