variable argument count

Discussion in 'iOS Programming' started by Sydde, Sep 8, 2010.

  1. Sydde macrumors 68020

    Sydde

    Joined:
    Aug 17, 2009
    #1
    This is a rather fundamental C question: what is the technique for scanning a variable argument list?

    For instance, if I wanted to write a method to add an indeterminate number of non-zero integers to a NSMutableArray, would it look something like this?

    Code:
    - (void)append:(NSMutableArray *)anArray withNumbers:(NSInteger)firstNumber, ... {
       NSInteger    *aNumber = &firstNumber;
       while ( 0 != *aNumber ) {
          [anArray appendObject:[NSNumber numberWithInteger:*aNumber]];
          aNumber += 1 ;
       }
    }
    
     

Share This Page