6

Prior to Xcode 4.3, if you wanted to use a method before you declared its implementation, you were required to forward declare the method (as with a C function prototype). This would usually be done in a class continuation (AKA class extension, private category). There's a good example in this question: Private Methods in Objective-C, in Xcode 4.3 I no longer need to declare them in my implementation file ?.

As of 4.3, this is no longer required; DRYers rejoice.

But can this magic be turned off, returning to the pre-4.3 behavior?

Community
  • 1
  • 1
Clay Bridges
  • 11,602
  • 10
  • 68
  • 118
  • Can you elaborate on why you want the warnings? Is it so people using older tools don't get build warnings you can't see? – Vincent Gable Apr 02 '12 at 21:31
  • 3
    Some folks find class continuations as useful as header files to see "private" methods at a glance. – Sandy Apr 02 '12 at 21:34
  • You also want the warning when you share code between Xcode 4.3 and 4.2 users. Otherwise the Xcode 4.3 users check-in code that won't compile under Xcode 4.2. – EricS Apr 02 '12 at 21:48
  • @Sandy You can still add forward declarations if you like, and if you do the compiler will still warn if they are NOT implemented. FWIW: Clicking on the end of the "Jump Bar" is how I scan the methods in a class http://developer.apple.com/library/ios/recipes/xcode_help-jump_bar/Recipe.html – Vincent Gable Apr 02 '12 at 22:10
  • @EricS the best suggestion I can offer is to make a scheme that uses "LLVM GCC 4.2" as the compiler, since it will warn, and build with it before checking in. I know this isn't great, and may not work if you use features that require LLVM :-( – Vincent Gable Apr 02 '12 at 22:22
  • @VincentGable Unfortunately, without anything to enforce forward declaration at build time, it's inevitable that methods would get missed. I think we'll just have to remove this requirement from our team's coding standards. – Sandy Apr 03 '12 at 19:57

1 Answers1

3

Currently this is not possible. The parsing behavior for Objective-C was changed to no longer require forward declarations.

Vincent Gable
  • 3,455
  • 23
  • 26
  • 1
    I just confirmed that even with -Weverything enabled, this does not result in an error. So there appears to be no warning flag to get the behavior desired by Clay. – Sandy Apr 02 '12 at 21:46