“Cannot find interface declaration for NSObject”?

前端 未结 7 548
礼貌的吻别
礼貌的吻别 2020-12-15 08:09

So I\'ve done some research into this issue, but I haven\'t found anything similar just yet...

So I\'m coding a game in Obj-C using Xcode and Sparrow Framework. I\'v

相关标签:
7条回答
  • 2020-12-15 09:04

    It sounds like you may have a circular reference in one of your header files.

    This can happen when foo.h #imports "bar.h" and bar.h #imports "foo.h" (or sometimes its a chain of three or more header files importing each other in a circle) and it leads to spurious errors like the one you're seeing.

    The solution is to try to avoid importing headers in your .h files, and instead use @class references for external classes in the .h files and put the #imports in the .m files instead. So instead of writing:

    #import "SomeClass.h"
    

    In your .h files, whenever possible put:

    @class SomeClass;
    

    In your .h file, and put the #import statement in your .m file instead.

    0 讨论(0)
提交回复
热议问题