Following the sample in article http://cocoawithlove.com/2009/05/variable-argument-lists-in-cocoa.html, I've written some custom handling of variable argument methods for forwarding them to another method.
- (void) someMethod:(NSString *)name
wittParamsAndKeys:(id)firstParam, ... {
va_list args;
va_start(args, firstParam);
NSDictionary* paramsAndKeys =
[[NSDictionary alloc] initWithObjectsAndKeys:firstParam, args, nil];
va_end(args);
}
But I get EXC_BAD_ACCESS. So then I tried removing nil
from arguments to NSDictionary:
NSDictionary* paramsAndKeys =
[[NSDictionary alloc] initWithObjectsAndKeys:firstParam, args];
Again the exception. Now I've got an exception from initWithObjectsAndKeys:
for invalid parameters.
I'm wondering if some way exists for just forwarding variable arguments to another method?