Saturday, July 17, 2010

"(class) may not respond to (method)"

Man, that message gets annoying. It's easy enough to get rid off, just put the method declaration in the interface/.h file. But maybe you don't want in the interface. You're calling it from within the class, why can't the compiler find it? Beside, your app runs fine regardless of the warning. Say you have the following:
- (void) applicationDidFinishLaunching:(NSNotification *)aNotification {
[self someInitialization];
}

- (void) someInitialization {
// Do some stuff
}
Swap the two around so that the method being called comes before the method doing the calling:
- (void) someInitialization {
// Do some stuff
}

- (void) applicationDidFinishLaunching:(NSNotification *)aNotification {
[self someInitialization];
}
And "ta da!", the warning goes away.

I'm not a particularly big fan of having to reorder my methods to please the compiler but I'm even less of a fan of having compiler warnings even when I know they're innocuous.