title: Objective-C va_list and selectors
body: <p>Is it possible to use <code>@selector</code> and <code>performSelector:</code> (or similar) with methods using variable arguments list?</p>
  
  <p>I'm writing a class that can be assigned a delegate to override the default behavior. In the presence of a delegate select method calls made on an instance of that class will be forward to the same corresponding delegate method, some which use variable argument lists.</p>
  
  <p>So, for instance, I need to be able to create retrieve <code>SEL</code> reference and message the delegate object with a method such as this:</p>
  
  <pre><code>- (void)logEventWithFormat:(NSString *)format, ... {
      va_list argList;
      id del = self.delegate;
      if (del != nil &amp;&amp; 
          [del conformsToProtocol:@protocol(AProtocolWithOptionalMethods)] &amp;&amp;
          [del respondsToSelector:@selector(logEventWithFormat:)])
      {
          // Perform selector on object 'del' with 'argList'
      }
  }
  </code></pre>
  
  <p>I am assuming this is not possible, hence the similar method declaration in the Foundation framework - in <code>NSString</code>:</p>
  
  <pre><code>- (id)initWithFormat:(NSString*)format, ...;
  </code></pre>
  
  <p>and </p>
  
  <pre><code>- (id)initWithFormat:(NSString *)format arguments:(va_list)argList;
  </code></pre>
  
  <p>I assume that the protocol I wish to delegate to should suggest the implementation of:</p>
  
  <pre><code>- (void)logEventWithFormat:(NSString *)format arguments:(va_list)argList;
  </code></pre>
  
  <p>so I the selector <code>@selector(logEventWithFormat:arguments:)</code> can be used an called with:</p>
  
  <pre><code>[del performSelector:@selector(logEventWithFormat:arguments:) 
            withObject:format
            withObject:argList];
  </code></pre>
  
  <p>I just wondered if I was missing something or going the long way around to achieve what I'm trying to?</p>