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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top