Hey, I'm struggling with weird problem when I try read varargs on my device (iphone6s). Everytime va_args is called returns messed up pointer which doesn't return proper object and cause EXEC_BAD_ACCESS when NSInvocation is invoked.
The same code run on Simulator and IPhone 4s works well.
void (*actionSelectorImplementationBlock) = ^(id self_, ...) {
// Initialize invocation etc.
// ......
va_list arguments;
a_start(arguments, self_);
NSUIntegerarg_count = [methodSignature numberOfArguments];
for(NSUInteger i = 0; i < arg_count - 2; i++ ) {
NSUInteger idx = i+2; const char *type = [methodSignature getArgumentTypeAtIndex:idx];
id arg = va_arg(arguments, id);
[invocation setArgument:&arg atIndex:idx];
}
va_end(arguments);
// Call invocation etc.
// .......
}
IMP newImplementation =imp_implementationWithBlock(actionSelectorImplementationBlock);
method_setImplementation(originalMethod, newImplementation);