Can anyone enlighten me as to the differences between the two statements below.
[self playButtonSound];
AND:
[self performSelector:@selector(playButtonSound)];
I am just asking as I had some old code that used @selector, now with a little more knowledge I can’t think why I did not use [self playButtonSound] instead, they both seem to do the same as written here.
gary
Both to the same thing, but
[self playButtonSound];is definitely the normal way to invoke a method in Objective-C. However, usingperformSelector:allows you to call a method that is only determined at runtime.From the NSObject Protocol Reference: