问题
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
回答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.
来源:https://stackoverflow.com/questions/5970874/xcode-4s-code-completion-for-methods-in-the-h-file