32

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".

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.

Shawn Sharp
  • 471
  • 1
  • 4
  • 12
  • you haven't included code !? which error do you get? how do you expect this to get solved? I doubt there are much psychic people here @ SO. – ant Apr 30 '12 at 17:09
  • 6
    The error I get is "No visible @interface for...". I included it in the title but probably should have included it in the description as well. – Shawn Sharp Apr 30 '12 at 17:18

7 Answers7

11

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

They had a typo in the selector name

Community
  • 1
  • 1
Lou Franco
  • 87,846
  • 14
  • 132
  • 192
2

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 error and those methods need to be at least declared privately

JoeCortopassi
  • 5,083
  • 7
  • 37
  • 65
  • 2
    The compiler pre-Xcode 4.2 will also allow you to use undeclared methods without error, provided that they are defined in the file prior to their use. – jscs Apr 30 '12 at 18:46
2

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

ratbum
  • 1,030
  • 12
  • 29
2

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

Peter
  • 1,022
  • 9
  • 12
1

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

Jeremias Erbs
  • 1,925
  • 2
  • 13
  • 7
0

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.

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

enter image description here

yoAlex5
  • 29,217
  • 8
  • 193
  • 205
0

I had this problem with NSSavePanel -beginSheetModalForWindow::, which obviously exists. I tried doing a clean rebuild as well as deleting the DerivedData, but no luck. I had copy-pasted and then modified, but I commented that out and typed out the call to -beginSheetModalForWindow and it started working. As far as I can tell I did not have any mistakes in the original call.

prewett
  • 1,587
  • 14
  • 19