SEL theSelector = NSSelectorFromString(@"setOrientation:animated:");
NSInvocation *anInvocation = [NSInvocation
invocationWithMethodSignature:
[MPMoviePlayerController instanceMethodSignatureForSelector:theSelector]];
[anInvocation setSelector:theSelector];
[anInvocation setTarget:theMovie];
UIInterfaceOrientation val = UIInterfaceOrientationPortrait;
BOOL anim = NO;
[anInvocation setArgument:&val atIndex:2];
[anInvocation setArgument:&anim atIndex:3];
[anInvocation invoke];
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- (BOOL)performBoolSelectorFromString:(NSString *)selStr
{
BOOL result;
SEL theSelector = NSSelectorFromString(selStr);
NSInvocation *anInvocation = [NSInvocation
invocationWithMethodSignature:
[[self class]
instanceMethodSignatureForSelector:theSelector]];
[anInvocation setSelector:theSelector];
[anInvocation setTarget:self];
[anInvocation invoke];
[anInvocation getReturnValue:&result];
return result;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- (NSInteger)testSelectorString:(NSString *)string integer:(NSInteger)integer {
return [string intValue] + integer + 1;
}
- (void)test {
SEL theSelector = @selector(testSelectorString:integer:);
NSInvocation *anInvocation = [NSInvocation invocationWithMethodSignature:[ClassName instanceMethodSignatureForSelector:theSelector]];
[anInvocation setSelector:theSelector];
[anInvocation setTarget:self];
NSInteger integer = 4;
NSString *string = @"3";
[anInvocation setArgument:&string atIndex:2];
[anInvocation setArgument:&integer atIndex:3];
[anInvocation invoke];
NSInteger result;
[anInvocation getReturnValue:&result];
NSLog(@"%d", result);
}