ok without using NSInvocation, let’s say I have this code:
...
array = [NSMutableArray arrayWithObjects:@"Yoda", @"Jedi", @"Darth Vader", @"Darth Vader", @"Darth Vader" , @"Darth Vader", nil];
SEL removeObjectMessage = @selector(removeObject:inRange:);
//does array allow us to remove and object in a range? if so let's do this
if ([array respondsToSelector:removeObjectMessage]){
NSRange darthVaderRange=NSMakeRange(2, 3);
[array removeObject:@"Darth Vader"inRange:darthVaderRange];
}
how would I perform that last line in the form of the SEL removeObjectMessage? I would have to put a wrapper around the range? I just want to see the syntax of how all that mess would look…
Unfortunately, if you’re passing an argument that’s not of type
id, you have to use anNSInvocationobject. (Otherwise, you could useperformSelector:withObject:withObject:.)