4

In Xcode 3 I could first write my method in the implementation (.m) file; afterwards adding the same method to the interface (.h) file. At that point Xcode 3 made a code completion for the method written in the .m file. Sadly, Xcode 4 doesn't code complete my methods like Xcode 3 did. Does anyone else encountered this, and is there an option for this case?

An example:

The implementation .m file could look like this:

#import "Foundation, MyClass.h and stuff"

@implementation MyClass

-(void)mySampleMethod { NSLog(@"mySampleMethod"); }

@end

The interface .h file could look like this:

#import "Foundation and stuff"

@interface MyClass : MySuperClass {

 }

-(void)myS /* in Xcode 3 the code completion would now pop up with the 'mySampleMethod' from the .m, in Xcode 4 this does not happen */ ampleMethod; /* So I either copy/paste, or write the method */

@end
Gerald Eersteling
  • 1,244
  • 14
  • 28
  • I can't say I have, but your question would be how do I fix this, right? – Dair May 11 '11 at 23:39
  • Yup, I don't know how to fix this. Or did Apple removed it (for a reason)? – Gerald Eersteling May 12 '11 at 05:29
  • It works for me the other way. Xcode can complete what it knows in the context. When you're writing .m file, corresponding .h file is included so it can autocomplete method names. – Peter Štibraný May 12 '11 at 06:00
  • It's true that it works the other way around. And yes, probably because of the #import of the .h file. But it would be awkward to import the .m file in the .h to achieve the results... – Gerald Eersteling May 12 '11 at 07:19

1 Answers1

1

Xcode 4's indexing for code completion and cross-referencing uses the LLVM compiler under the hood, which enables it to only present completions that are valid in the context in which you attempt to use them.

One downside of this (vastly) increased precision is that the completion you're looking for in this case isn't available.

Of course, remember that in Objective-C only methods a class is actually exposing to another class need to be declared in header file for the class.

Chris Hanson
  • 54,380
  • 8
  • 73
  • 102