.h文件中方法的XCode 4代码完成 [英] XCode 4's code completion for methods in the .h file

查看:102
本文介绍了.h文件中方法的XCode 4代码完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Xcode 3中,我可以首先在实现( .m )文件中编写我的方法;然后将相同的方法添加到界面( .h )文件中.那时,Xcode 3为 .m 文件中编写的方法完成了代码编写.可悲的是,Xcode 4不能像Xcode 3那样完成我的方法.还有其他人遇到过这种情况吗?这种情况下可以选择吗?

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?

一个例子:

.m文件的实现看起来像这样:

#import "Foundation, MyClass.h and stuff"

@implementation MyClass

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

@end

接口.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索引在幕后使用了LLVM编译器,这使它仅能显示在以下情况下有效的完成内容:您尝试使用它们.

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.

当然,请记住,在Objective-C中,只有一个类实际上暴露给另一个类的方法才需要在该类的头文件中声明.

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.

这篇关于.h文件中方法的XCode 4代码完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆