We have the following method, which works for objects. It takes a method on an object and places the result in returnValueContainer:
+ (void)invokePrivateMethod:(SEL)selector returnValueContainer:(NSObject **)returnValueContainer onObject:(NSObject *)object {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[object class] instanceMethodSignatureForSelector:selector]];
[invocation setSelector:selector];
[invocation setTarget:object];
[invocation invoke];
[invocation getReturnValue:returnValueContainer];
}
Is it possible to modify this somehow so that we can return primitives (e.g. NSInteger) as well as objects from getReturnValue?
Background: we are trying to access a private primitive property on a class for unit tests.