以下是我从Apple的“计时器编程主题”中看到的示例代码:
NSMethodSignature *methodSignature = [self methodSignatureForSelector:@selector(invocationMethod:)]; NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSignature]; [invocation setTarget:self]; [invocation setSelector:@selector(invocationMethod:)]; NSDate *startDate = [NSDate date]; [invocation setArgument:&startDate atIndex:2];
正如您所看到的,我们必须在NSMethodSignature中指定invocationMethod:once,然后在NSInvocation的setSelector中指定第二次.
对我来说,这似乎是多余的,苹果设计有这样的理由吗?