Skip to content

Instantly share code, notes, and snippets.

@paulrehkugler
Last active January 2, 2016 03:29
Show Gist options
  • Save paulrehkugler/8243948 to your computer and use it in GitHub Desktop.
Save paulrehkugler/8243948 to your computer and use it in GitHub Desktop.
- (id)initWithCancelButtonTitle:(NSString *)cancelTitle otherButtonTitles:(NSString *)otherButtonTitles, ... {
if (self = [super init]) {
NSMutableArray *buttonTitles = [[NSMutableArray alloc] init];
BRYEachArgumentBlock eachArgumentBlock = ^(NSString *title) {
[buttonTitles addObject:title];
};
BRYVarArgs(eachArgumentBlock, otherButtonTitles);
}
return self;
}
typedef void (^BRYEachArgumentBlock)(id argument);
void BRYVarArgs(BRYEachArgumentBlock eachArgumentBlock, id arguments, ...) {
if (arguments && eachArgumentBlock) {
va_list argumentList;
va_start(argumentList, arguments);
while ((argument = va_arg(argumentList, id))) {
eachArgumentBlock(argument);
}
va_end(argumentList);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment