I noticed this in Joe Hewitt's source for Three20 and I've never seen this particular syntax in Objective-C before. Not even sure how to reference it in an appropriate Google search.
From TTTableViewDataSource:
+ (TTSectionedDataSource*)dataSourceWithObjects:(id)object,... {
The "..." is what's throwing me off here. I'm assuming it's a form of enumeration where a variable amount of arguments may be supplied. If it is, what's the official name for this operator and where can I reference the documentation for it?
Thank you kindly.
It's a variadic method, meaning it takes a variable number of arguments. This page has a good demonstration of how to use it:
#import <Cocoa/Cocoa.h>
@interface NSMutableArray (variadicMethodExample)
- (void) appendObjects:(id) firstObject, ...; // This method takes a nil-terminated list of objects.
@end
@implementation NSMutableArray (variadicMethodExample)
- (void) appendObjects:(id) firstObject, ...
{
id eachObject;
va_list argumentList;
if (firstObject) // The first argument isn't part of the varargs list,
{ // so we'll handle it separately.
[self addObject: firstObject];
va_start(argumentList, firstObject); // Start scanning for arguments after firstObject.
while (eachObject = va_arg(argumentList, id)) // As many times as we can get an argument of type "id"
[self addObject: eachObject]; // that isn't nil, add it to self's contents.
va_end(argumentList);
}
}