好的,不使用NSInvocation
,假设我有这个代码:
...
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];
}
我将如何以 SEL removeObjectMessage 的形式执行最后一行?我必须在范围周围放一个包装器吗?我只想看看所有这些乱七八糟的语法......