Jamal Zafar
Jamal Zafar

Reputation: 2189

What is this convention in method declaration?

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?

Upvotes: 0

Views: 85

Answers (1)

pb2q
pb2q

Reputation: 59617

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.

Upvotes: 3

Related Questions