接收器类型***例如消息是前向声明 [英] receiver type *** for instance message is a forward declaration

查看:111
本文介绍了接收器类型***例如消息是前向声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iOS5应用程序中,我有 NSObject States class,并尝试初始化它:

  states = [states init]; 

此处 init <$ c>中的方法$ c> States :

   - (id)init 
{
if((self = [super init]))
{
pickedGlasses = 0;
}

返回自我;
}

但行 states = [ state init];


接收者类型States例如消息是前向声明


这是什么意思?我做错了什么?

解决方案

这基本上意味着你需要导入包含状态声明的.h文件。 / p>

然而,您的代码中存在其他错误的很多




  • 你是在没有 + alloc 的情况下发出一个对象。这将无法正常工作

  • 您将对象声明为非指针类型,无法正常工作

  • 您不是在 -init 中调用 [super init]

  • 您已声明标题中使用 @class 的类,但从未导入该类。


In my iOS5 app, I have NSObject States class, and trying to init it:

states = [states init];

here is init method in States:

- (id) init
{
    if ((self = [super init]))
    {
        pickedGlasses = 0;
    }

    return self;
}

But there is error in the line states = [states init];

receiver type "States" for instance message is a forward declaration

What does it mean? What am I doing wrong?

解决方案

That basically means that you need to import the .h file containing the declaration of States.

However, there is a lot of other stuff wrong with your code.

  • You're -init'ing an object without +alloc'ing it. That won't work
  • You're declaring an object as a non-pointer type, that won't work either
  • You're not calling [super init] in -init.
  • You've declared the class using @class in the header, but never imported the class.

这篇关于接收器类型***例如消息是前向声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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