Private Methods in Objective-C, in Xcode 4.3 I no longer need to declare them in my implementation file ?

As of the LLVM Compiler version shipped with Xcode 4.3, if you try to call a method that the compiler has not previously seen, it will look in the rest of the current @implementation block to see if that method has been declared later. If so, then it uses that, and you don’t get a warning. Hence, as of Xcode 4.3, there’s much less need to pre-declare your internal methods. Clearly, you still need to declare methods that are publicly exposed to other classes.

This change was noted in the release notes of some of the Xcode 4.3 betas, but apparently didn’t make it into the “What’s New in Xcode 4.3” final documentation.

Unlike has been suggested in other answers, this is not just an “Undeclared Selector” warning that has been turned off by default. In fact, if you’re using ARC, unrecognized selectors are still hard errors. Try calling [self myNonexistentMethod] and you’ll see; the compiler still complains.

Leave a Comment