“找不到NSObject的接口声明"? [英] "Cannot find interface declaration for NSObject"?

查看:230
本文介绍了“找不到NSObject的接口声明"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我已经对该问题进行了一些研究,但是我还没有发现任何类似的东西...

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

因此,我正在使用Xcode和Sparrow Framework在Obj-C中编写游戏.到目前为止,我一直在开发模拟器,并且一切都很好.但是,当我切换到在设备上运行它时,对于应该是标准的东西,我会遇到各种错误,例如找不到NSObject的接口声明",未知类型名称'NSMutableArray'"等.我已经在每个类中获取了#import,所以您会认为它不应该发生,对吧?我觉得只是一两行需要更改某个地方-但我不知道什么地方在哪里.

So I'm coding a game in Obj-C using Xcode and Sparrow Framework. I've been working on the simulator up until this point, and it's all been going fine. But when I switch to running it on my device, I get all sorts of errors for things that should be standard, e.g. "Cannot find interface declaration for NSObject", "Unknown type name 'NSMutableArray'" etc. I've already got #import in each class, so you would think that it shouldn't happen, right? I get the feeling that it's just a line or two that needs changing somewhere - but I haven't got a clue what or where.

如果任何人有任何建议,我们将不胜感激. :)

If anyone has any advice, it would be very much appreciated. :)

这是出现错误的.h文件之一的屏幕截图-它似乎只存在于我创建的某些.h文件中. http://i.imgur.com/EuQh4.png

Here's a screenshot of one of the .h files that give errors - it seems to only be in some of the .h files that I've created. http://i.imgur.com/EuQh4.png

推荐答案

听起来您的头文件之一中可能有循环引用.

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

当foo.h #imports"bar.h"和bar.h #imports"foo.h"(或者有时是由三个或更多个头文件组成的链,彼此导入成一个圆圈)时,会发生这种情况像您看到的那样虚假的错误.

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.

解决方案是尝试避免在.h文件中导入标头,而是对@h文件中的外部类使用@class引用,而将#imports放在.m文件中.所以不用写:

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"

在您的.h文件中,尽可能放置:

In your .h files, whenever possible put:

@class SomeClass;

在.h文件中,将#import语句放在.m文件中.

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

这篇关于“找不到NSObject的接口声明"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆