Learning Cocoa: may not respond warnings…

Working on the RaiseMan application in Cocoa Programming For Mac OS X 2nd Ed, I kept getting ” ‘ClassName’ may not respond to ‘-methodName’ “warning messages on successful builds. The warnings were obviously stupid compiler warnings. Trouble is this: Objective-C (and thus Cocoa) does not care what order you implement methods in your .m file, BUT the compiler is just not clever enough to realize this and wait until later to generate warnings like this.Annoying. Especially so, when you consider, I knew this long ago, but had forgotten it. But to be sure, even though you can put methods in any order, when you get such erroneous warnings, check to see if the method flagged in the warning does not call a method that is defined later in the .m file. If you find this to be true, simply reorder your methods so you can build without warnings. Ideally, you should build successfully with few or no warnings. No warnings is always ideal. Compilers are clever tools but not perfect. The upside of this annoying defiance of the language? When you do get your methods in an order that generates no warnings, your code will be more readable and maintainable because no method will call another method that does not come before it!Finally, I don’t know if this has changed in XCode3. I doubt it, but I have not taken the plunge into Leopard, because I can’t afford to buy a new Mac capable of smoothly running Leopard. (and because I still don’t really like Leopard as much as Tiger and Panther, even though I use it at work every day… maybe another dot-update or two will bring me into the fold…) 

0 comments ↓

There are no comments yet...Kick things off by filling out the form below.

Leave a Comment