Следующий код работает должным образом:
NSLog(@"%@", [NSString stringWithString:@"test"]; // Logs "test"
Но когда я заменяю его на NSInvocation
, я получаю совершенно другой результат:
Class class = [NSString class];
SEL selector = @selector(stringWithString:);
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:
[class methodSignatureForSelector:selector]];
[invocation setTarget:class];
[invocation setSelector:selector];
[invocation setArgument:@"test" atIndex:2];
[invocation invoke];
id returnValue = nil;
[invocation getReturnValue:&returnValue];
NSLog(@"%@", returnValue); // Logs "NSCFString"
Я искалвысоко и низко, но не могу понять это.Любая помощь?Спасибо!