0

Compare...

NSInvocation* invocation = [NSInvocation invocationWithMethodSignature:[performer methodSignatureForSelector:@selector(playFile:)]];
[invocation setSelector:@selector(playFile:)];
[invocation setTarget:performer];
NSString* string = [NSString stringWithString:@"reverse.wav"];
[invocation setArgument:&string atIndex:2];

...with...

NSInvocation* invocation = [[NSInvocation prepareWithTarget:performer] playFile:@"reverse.wav"];

. Why isn't such a method implemented?

skaffman
  • 398,947
  • 96
  • 818
  • 769
andyvn22
  • 14,696
  • 1
  • 52
  • 74
  • 1
    You can make your code cleaner by using a variable for the selector `SEL sel = @selector(playFile:)`, which also avoids mistyping long selector names, and by just setting `NSString* string = @"reverse.wav"` - the `-stringWithString:` call is unnecessary. – Jeremy W. Sherman Oct 27 '10 at 17:23

1 Answers1

2

It just isn't, but there is no shortage of third-party implementations of the same functionality, such as the one written up at and created for Cocoa with Love.

Jeremy W. Sherman
  • 35,901
  • 5
  • 77
  • 111