2 ms·
He wants to be able to pass any Proc to his method, and any arguments supplied to the method are yielded onto target. A rough Objective-C equivalent would be so
by randomdata 15y ago
He wants to be able to pass any Proc to his method, and any arguments supplied to the method are yielded onto target. A rough Objective-C equivalent would be something like this:
void animate(void (^block)(va_list), ...)
{
va_list args;
va_start(args, block);
block(args);
va_end(args);
}
void (^first)(va_list) = ^(va_list args) {
NSLog(@"%@", va_arg(args, id));
};
void (^second)(va_list) = ^(va_list args) {
NSLog(@"%@", va_arg(args, id));
NSLog(@"%@", va_arg(args, id));
};
animate(first, @"Hello World");
animate(second, @"Hello", [[NSNumber alloc] initWithInt:10]);
I would like to see the real-world code too. The frameworks in question revolve around Obj-C-isms, so to see something that completely deviates from those patterns will be interesting.