Following the sample in the article http://cocoawithlove.com/2009/05/variable-argument-lists-in-cocoa.html , I wrote some special handling of variable argument methods to forward 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, I tried to remove nilfrom the arguments in NSDictionary:
NSDictionary* paramsAndKeys =
[[NSDictionary alloc] initWithObjectsAndKeys:firstParam, args];
Again an exception. Now I have an exception initWithObjectsAndKeys:for invalid parameters.
I am wondering if there is some way to simply forward the arguments of a variable to another method?
source
share