Created
August 11, 2011 09:33
-
-
Save gonecoding/1139278 to your computer and use it in GitHub Desktop.
Example of an Objective-C method with a variable list of arguments (va_list)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)methodName:(NSObject*)firstObject, ... NS_REQUIRES_NIL_TERMINATION; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)methodName:(NSObject*)firstObject, ... | |
{ | |
va_list args; | |
va_start( args, firstObject ); | |
for( NSObject* arg = firstObject; arg != nil; arg = va_arg( args, NSObject*) ) | |
{ | |
// do something using 'arg' here | |
} | |
va_end( args ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment