xcode XCode有警告时如何判断哪些方法没有实现
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8541876/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to determine which methods are not implemented when XCode has warnings
提问by Michael Peterson
Sometimes I have a interface that implements several protocols and I'll get a warning from XCode that my implementation is incomplete.
有时我有一个实现多个协议的接口,我会从 XCode 收到一个警告,说我的实现不完整。
Is there an easy way to determine which methods are "required" but but implemented (without having to put in dummy implementations of all the non-optional methods from the protocol header files)?
是否有一种简单的方法可以确定哪些方法是“必需的”但已实现(无需从协议头文件中放入所有非可选方法的虚拟实现)?
For example, I have a warning on this interface but I don't want to have to dig through all the protocols.. obviously XCode knows that some are missing, why can't it just tell which they are!
例如,我在这个界面上有一个警告,但我不想深入研究所有的协议..显然 XCode 知道有些丢失了,为什么它不能告诉它们是哪些!
@interface KTThumbsViewController : UIViewController <KTThumbsViewDataSource, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIAlertViewDelegate>
XCode 4
代码 4
回答by ericsoco
Didn't find the answer here, unfortunately. But a bit more digging turned up an answer, in the Issue navigator in the Navigator View.
不幸的是,在这里没有找到答案。但是在导航器视图的问题导航器中,更多的挖掘找到了答案。
Open the Navigator view via the View buttons at upper-right:
通过右上角的视图按钮打开导航器视图:
Then open the Issue navigator via the triangle/exclamation mark button at upper-left:
然后通过左上角的三角形/感叹号按钮打开问题导航器:
If you expand your "Incomplete implementation" Semantic Issue with the little triangle at left, you can see the details of XCode's complaint.
如果你用左边的小三角形展开你的“不完整的实现”语义问题,你可以看到 XCode 投诉的详细信息。
回答by Antwan van Houdt
Press alt and click on the protocol, xcode will show you where it is defined so you can take a look at the header file. Alternatively in the "issues" tab it will show you which methods you did not implement yet.
按 alt 并单击协议,xcode 将显示它的定义位置,以便您查看头文件。或者,在“问题”选项卡中,它会显示您尚未实施的方法。
回答by BrianS
As a followup to this
作为这个的后续
Sometimes "Incomplete Implementation" really means "Mismatch between the function prototype and the implemented function".
有时“不完整的实现”真的意味着“函数原型和实现的函数之间不匹配”。
For example, if in your .h file you had this:
例如,如果在您的 .h 文件中有这样的内容:
- (NSTimeInterval) SayDigit: (int) score;
But in your .m file you had this:
但是在你的 .m 文件中你有这个:
- (NSTimeInterval) SayDigit: (int) digit: (NSTimeInterval) time
You would get the "Incomplete Implementation" warning.
您会收到“未完成实施”警告。