ios 没有可见的@interface

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10387330/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 18:10:59  来源:igfitidea点击:

No visible @interface for

objective-ciosxcodeinterface

提问by Shawn Sharp

I have gotten this error on several occasions and am unclear as to what causes the error in general. After looking for over an hour on stack overflow and google I still don't have an answer. Could someone help?

我已经多次收到此错误,并且不清楚一般是什么原因导致了该错误。在堆栈溢出和谷歌上寻找一个多小时后,我仍然没有答案。有人可以帮忙吗?

I've seen several specific answers but nothing that says why the error happens, only "do x", or "do y".

我已经看到了几个具体的答案,但没有说明错误发生的原因,只有“do x”或“do y”。

I haven't included code yet because I want to know the reason that this error happens in general so I can fix my code in the future whenever I get this error.

因为我想知道原因,这个错误一般发生这样我就可以固定在未来我的代码时,我得到这个错误我没有包含的代码呢。

回答by Lou Franco

There are lots of reasons it could happen, but generally it's saying that at the line of code it flags, it doesn't see any evidence that the selector you are referencing is in the interface of the type it thinks the object has.

它可能发生的原因有很多,但通常是说在它标记的代码行中,它没有看到任何证据表明您引用的选择器位于它认为对象具有的类型的接口中。

In this example,

在这个例子中,

No visible interface error

没有可见的界面错误

They declared operandStack with the wrong type.

他们用错误的类型声明了操作数堆栈。

In this one

在这一

http://www.raywenderlich.com/forums/viewtopic.php?f=2&t=3312

http://www.raywenderlich.com/forums/viewtopic.php?f=2&t=3312

They had a typo in the selector name

他们在选择器名称中有一个错字

回答by JoeCortopassi

Any chance you are on Xcode 4.2 (or less), running code that was written on Xcode 4.3? In 4.3+ Xcode doesn't require you to declare private methods at all, it just assumes that methods written in the implementation file (without declarations in the interface) are private. But in Xcode <= 4.2, this will throw an errorand those methods need to be at least declared privately

您是否有机会使用 Xcode 4.2(或更低版本)运行在 Xcode 4.3 上编写的代码?在4.3+ 中,Xcode 根本不需要你声明私有方法,它只是假设在实现文件中编写的方法(在接口中没有声明)是私有的。但是在Xcode <= 4.2 中,这将引发错误,并且这些方法至少需要私下声明

回答by ratbum

I just had this problem; mine was caused by me setting the method as a class method rather than an instance method. Very silly.

我刚刚遇到了这个问题;我的原因是我将方法设置为类方法而不是实例方法。很傻。

回答by Peter

Another reason can be when using categories in libraries and you haven't set -ObjC (or -all_load) in the Other Linker Flags

另一个原因可能是在库中使用类别时您没有在其他链接器标志中设置 -ObjC(或 -all_load)

回答by Jeremias Erbs

Another common error ist to forget to write [someInstance setSomeValue:3]; instead of [someInstance someValue:3] (<- wrong). That what happened to me.

另一个常见的错误是忘记写 [someInstance setSomeValue:3]; 而不是 [someInstance someValue:3] (<- 错误)。那是发生在我身上的事情。

回答by yoAlex5

When I have run into this problem it turned out that Xcode had not reindexed files after changing Git branch. The solution is Delete Derived Data.

当我遇到这个问题时,结果是 Xcode 在更改 Git 分支后没有重新索引文件。解决办法是Delete Derived Data

Using Xcode version 10.0 File -> Workspace Settings...(or Project Settings...) -> click on the little green circle and manually remove all files in DerivedData folder

使用 Xcode 10.0 版 File -> Workspace Settings...(or Project Settings...) -> click on the little green circle and manually remove all files in DerivedData folder

enter image description here

在此处输入图片说明