Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The ellipsis (...) is inherited from C; you can use it only as the final argument in a call (and you've missed out the relevant comma in your example). So in your case you'd probably want:</p> <pre><code>+ (void)doSomethingToObjects:(id)firstObject, ...; </code></pre> <p>or, if you want the count to be explicit and can think of a way of phrasing it well:</p> <pre><code>+ (void)doManyTimes:(NSInteger)numberOfTimes somethingToObjects:(id)firstObject, ...; </code></pre> <p>You can then use the normal C methods for dealing with ellipses, which reside in stdarg.h. There's a quick documentation of those <a href="http://pubs.opengroup.org/onlinepubs/007908799/xsh/stdarg.h.html" rel="nofollow noreferrer">here</a>, example usage would be:</p> <pre><code>+ (void)doSomethingToObjects:(id)firstObject, ... { id object; va_list argumentList; va_start(argumentList, firstObject); object = firstObject; while(1) { if(!object) break; // we're using 'nil' as a list terminator [self doSomethingToObject:object]; object = va_arg(argumentList, id); } va_end(argumentList); } </code></pre> <p>EDIT: additions, in response to comments. You can't pass the various things handed to you in an ellipsis to another function that takes an ellipsis due to the way that C handles function calling (which is inherited by Objective-C, albeit not obviously so). Instead you tend to pass the va_list. E.g.</p> <pre><code>+ (NSString *)doThis:(SEL)selector makeStringOfThat:(NSString *)format, ... { // do this [self performSelector:selector]; // make string of that... // get the argument list va_list argumentList; va_start(argumentList, format); // pass it verbatim to a suitable method provided by NSString NSString *string = [[NSString alloc] initWithFormat:format arguments:argumentList]; // clean up va_end(argumentList); // and return, as per the synthetic example return [string autorelease]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload