Unexpectedly, I've got decent solution from PR on Github so all credits go to @sandor-gazdag. Here's solution:
- (void)forwardInvocation:(NSInvocation *)inv {
NSUInteger n = [[inv methodSignature] numberOfArguments];
NSMutableArray *parameterList = [[NSMutableArray alloc] init];
for (NSUInteger i = 0; i < n - 2; i++) {
id __unsafe_unretained arg;
[inv getArgument:&arg atIndex:(int)(i + 2)];
if (!arg) {
arg = [NSNull null];
}
[parameterList addObject:arg];
}
[self dynamicWebServiceCallWithArguments:parameterList forInvocation:inv];
}
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {
NSUInteger numArgs = [[NSStringFromSelector(aSelector) componentsSeparatedByString:@":"] count] - 1;
return [NSMethodSignature signatureWithObjCTypes:[[@"@@:@" stringByPaddingToLength:numArgs + 3 withString:@"@" startingAtIndex:0] UTF8String]];
}
- (void)dynamicWebServiceCallWithArguments:(NSMutableArray *)parameterList forInvocation:(NSInvocation *)invocation {
...
id result = [self executeDynamicInstanceMethodForSelector:invocation.selector parameters:parameterList prepareToLoadBlock:prepareToLoadBlock success:successBlock failure:failureBlock];
[invocation setReturnValue:&result];
}
So simple and still so powerful. Works for any processor architecture, because it's high-level solution. I blame myself that I've not find it myself=)