Quick reminder about Objective-C selectors
So I spent a good 15 minutes scratching my head over an exception being thrown in Xcode:
2012-03-12 16:14:50.321 MediaPlayground[10032:11f03] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[ViewController playMovieFinished]: unrecognized selector sent to instance 0x7d52e20’
So naturally I go to the playMovieFinished method and take a look at the selector being defined. Everything looked okay to me. After doing some digging around, I finally figured out what the problem was and it was a really dumb one. Turns out I was missing a : at the end of the selector method name.
The Method in Question:
- (void)playMovieFinished:(NSNotification *)theNotification;
What I Had:
What I Needed:
This is just a quick reminder that could save precious time debugging little things that the compiler should really flag down. Also this only applies to methods with arguments.
For methods with no arguments to be used as selectors, no : is needed.
The Parameterless Method:
What is Needed: