3
我有一個方法,它採用類似這樣的可變參數,參數以nil結尾。在NSInvocation中傳遞帶有可變參數的方法的多個參數
-(void)manyParams:(NSString *)st, ... {
va_list argList;
va_start(argList,st);
id obj;
while ((obj = va_arg(argList, id))) {
NSLog(@"%@",obj);
}
va_end(argList);
return;
}
我如果我使用NSInvocation
類調用manyParams話,我怎麼能做到這一點
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setTarget:self];
[invocation setSelector:@selector(manyParams:)];
///NSString *one = @"one";
///[invocation setArgument:&one atIndex:2]; //////How to pass variable arguments like @"one",@"two",@"three", nil
[invocation invoke];
」 ..union參數「 - 那是什麼? –
C聯合。請參閱:https://www.tutorialspoint.com/cprogramming/c_unions.htm – ipmcc
瞭解它,謝謝@ipmcc –