No visible #interface for - objective-c

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.

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

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

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

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

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

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

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.

Related

How to get back the redefined DPC method which redefinition was deleted?

I have a DPC class in sap for a gateway service. I redefined a getEntitySet method and wrote some code in it.
Then I accidentally undid the redefinition and all my code is gone. Is there any way to get my code back?
Is there any way to get my code back?
Yes, unless you activated it. Just redefine it again and your former code will appear in the method automatically, you don't even need to go to Versions. If you see that method in the blue state, it is not yet activated.
If you deleted the redefinition and activated the method, this is the point of no return and you've lost the code forever. Undefinition does not cause automatic version generation.
However, you can prevent such situations to happen in future by making manual version generation. Just go to Utilities->Versions->Generate version after you implemented the method and that's it.
Now even (de)activation and (un)definition is not a problem for you, you'll always have YOUR version type U in the database.

Is there a way to show warning on not using weak self?

Every few months, I get the same problem of a ViewController not getting dealloced because of not using weak-self in a block.
Is there any way of making Xcode warn me about this?
Thanks.
This might help -Warc-retain-cycles
Also, if instead of Build, you choose Analyze in Xcode, this will give you more information about bad practices in the code which includes information about using weak variables.
Another level further is to use Infer, a static analyzer for iOS/Android that Facebook open sourced: www.fbinfer.com
Also, see: http://fuckingclangwarnings.com/ for other warnings. I just have '-w' set on my project to get all the standard warnings

XCode 4.5 warns about method name conflicts between Categories for parent/child classes

I'm working on a project that was originally built in XCode 4.0, and then migrated to using XCode 4.2. Now I've tested out migrating to XCode 4.5, and I'm getting a ton of warnings like below...
instance method 'values' in category from <pathToTheFile>/HistoryObject+extras.o conflicts with same method from another category
These warnings never appeared in previous versions of XCode, and the code hasn't changed.
The project is set at iOS 4.3 for the Deployment Target.
So, we have from a previous developer a bunch of DAO type classes that I believe were auto-generated from CoreData, and then each of these classes has a Category that extends it to implement certain methods. I'll give an example...
We have a base class named LisaObject that inherits from NSManagedObject, and it has a Category named LisaObject+extras. In LisaObject+extras, there is a method named "values" that returns an NSMutableDictionary.
We then have a class named HistoryObject that inherits from LisaObject. There is also a Category for HistoryObject that is named HistroyObject+extras. This Category also has a method named "values". In the HistoryObject+extras values method, it calls [super values], and then checks for some conditions and sets some additional values in the dictionary that aren't set in the base class method.
We then have a class named LessonStatusObject that inherits from HistoryObject, and it too has a Category named LessonStatusObject+extras, which has a method named values. This values method also calls [super values] and then does some additional work on the returned dictionary.
For each of these "values" methods, we get a warning at compile time like the one shown above where it says the Category has a method with a conflicting name.
I have a few questions about this.
First, could this implementation cause any legitimate problems, or are these warnings generally benign? I've tried to think of how this implementation could cause an ambiguity at runtime, but I don't see how that could happen.
Second, is there something that I should do to fix these warnings (and I don't mean just make them stop appearing; I mean fix the cause)? Is there some other way we should be going about this?
Also, why would XCode 4.2 not warn about this, but XCode 4.5 does warn?
Am I misunderstanding something about Categories? I mean, if the "values" method was actually part of the each class implementation, it wouldn't be a problem to override them the way we do, but the compiler seems to be complaining simply because these are Categories. Is there anything unsafe about this?
Any advice is much appreciated.
EDIT: Just to provide more information... When we were using XCode 4.2, the project had the compiler set to Apple LLVM Compiler 3.0. Now when I open the project in XCode 4.5, it has the compiler set to Apple LLVM Compiler 4.1.
I had this same annoying issue and it turned out that I had accidentally included that category's .m file instead of the .h file in one of my VC's code. Correcting it to the .h file removed the linker warnings.
Do not ignore the warning.
Apple's "Programming With Objective-C" guide, in the "Customizing Existing Classes" section, says:
If the name of a method declared in a category is the same as a method
in the original class, or a method in another category on the same
class (or even a superclass), the behavior is undefined as to which
method implementation is used at runtime.
If it has been working for you, then it's luck.
I had this issue too, but was caused by something different again. For me it was that the category had been added to the Xcode project twice! I didn't discover that was the case until I went to rename one of the methods and saw in the refactoring preview that it listed the category file twice.

clang: error: cannot specify both '-fobjc-arc' and '-fobjc-gc'

I do have Objective-C Automatic Reference Counting set to YES, but I have
Objective-C Garbage Collection set to Unsupported
So I don't see how -fobjc-gc could be getting set. Is there something else that also sets it that I haven't noticed? I've tried a clean build, so it's not something sticking around.
I found the answer, indirectly, thanks to this question. It turns out, that to get rid of garbage collection, I need to BOTH turn off garbage collection in the compiler settings when I click on Build Settings under the Project, and under the Target. If they disagree, the target (which is the one I didn't notice) overrides. No amount of playing with the settings at the project level was fixing that.

Disabling the "property's synthesized getter follows cocoa naming convention" warning

After upgrading Xcode to the 4.2, I'm going through and fixing all the new compiler warnings that I'm getting. One that is in a lot of places is the "property's synthesized getter follows Cocoa naming convention for returning 'owned' objects" warning. This is showing up in some code generated from web service WSDL files, so I don't want to change the property names just to satisfy a warning. Is there a compiler flag to disable these warnings? I've done the requisite googling, but I can't seem to find one.
I think the consensus is that a compiler flag like this doesn't exist, so the best route (in my situation) is to try to get the third party code generator to handle this appropriately.