【问题标题】:Sending / Forwarding variable arguments in ObjectiveC在 Objective C 中发送/转发变量参数
【发布时间】:2012-06-07 04:30:17
【问题描述】:

我知道这在其他编程语言中是可能的。假设我们有以下安排:

- (void) myMethod:(NSString*)variables, ... {
    // Handle business here.
}

- (void) anotherMethod:(NSString*)variables, ... {
    // We want to pass these variable arguments for handling
    [self myMethod:variables, ...]; // Do not pass GO
}

// Start the party:
[self anotherMethod:@"arg1", @"arg2", @"arg3", @"arg4", nil];

让这个在 ObjC 中工作的诀窍是什么?

【问题讨论】:

标签: objective-c variables ios5 variable-assignment


【解决方案1】:

是的。在 objective-c 中是可能的。你可以找到关于 here 的好文章。

【讨论】:

  • 但是如何帮助转发可变参数调用?
  • 这个链接没有告诉任何事情来帮助实现 OP 想要的,尤其是如何转发可变参数。
  • 是的。它使用va_list,va_args,通常不解决this problem
  • @JBL,您提到的问题与变量参数传递无关。这是 UIAlertView 中的一个特定故障。该链接确实有助于提问者,因此答案被接受。我不认为反对票是合理的。
  • @Vignesh UIAlertView 中确实存在故障,但如果有正确的方法来转发可变参数,这实际上可以解决。 (哦,顺便说一句,我根本没有对这个问题投票,因为我不会说它没有用,正如它已被接受的事实所示)
猜你喜欢
  • 2011-07-20
  • 2011-11-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-09-14
相关资源
最近更新 更多