Question

I have seen someone declaring a method in Objective C like this:

- (FMResultSet *)executeQueryWithFormat:(NSString*)format, ...;

Can anyone tell me what does the dotted notation at the end of the method declaration represent here?

Was it helpful?

Solution

The ... represents a variable-length argument list, analogous to a variadic function in standard C. It indicates that the message can accept a variable number of arguments.

Within the message implementation variadic arguments are handled just the same way as in a standard C function, except in Objective-C the argument list is typically nil terminated. The same header file stdarg.h is used, and the same va_list type and associated macros for manipulating the list.

See this OS X Developer document for an example; and some standard C examples here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top