简体   繁体   English

XCode 4的代码完成.h文件中的方法

[英]XCode 4's code completion for methods in the .h file

In Xcode 3 I could first write my method in the implementation ( .m ) file; 在Xcode 3中,我可以在实现( .m )文件中编写我的方法; afterwards adding the same method to the interface ( .h ) file. 然后将相同的方法添加到接口( .h )文件。 At that point Xcode 3 made a code completion for the method written in the .m file. 此时,Xcode 3为.m文件中编写的方法完成了代码。 Sadly, Xcode 4 doesn't code complete my methods like Xcode 3 did. 可悲的是,Xcode 4并没有像Xcode 3那样编写完整的方法。 Does anyone else encountered this, and is there an option for this case? 有没有其他人遇到过这种情况,是否有这种情况的选择?

An example: 一个例子:

The implementation .m file could look like this: 实现.m文件可能如下所示:

#import "Foundation, MyClass.h and stuff"

@implementation MyClass

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

@end

The interface .h file could look like this: 接口.h文件可能如下所示:

#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

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. Xcode 4对代码完成和交叉引用的索引使用了LLVM编译器,这使得它只能呈现在您尝试使用它们的上下文中有效的完成。

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. 当然,请记住,在Objective-C中,只有一个类实际暴露给另一个类需要在类的头文件中声明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM