receiver type *** for instance message is a forward declaration

后端 未结 9 1001
心在旅途
心在旅途 2021-01-30 01:19

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

states = [states init];

here is init

相关标签:
9条回答
  • 2021-01-30 01:49

    I was trying to use @class "Myclass.h".

    When I changed it to #import "Myclass.h", it worked fine.

    0 讨论(0)
  • 2021-01-30 01:58

    You are using

    States states;
    

    where as you should use

    States *states;
    

    Your init method should be like this

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

    Now finally when you are going to create an object for States class you should do it like this.

    State *states = [[States alloc] init];
    

    I am not saying this is the best way of doing this. But it may help you understand the very basic use of initializing objects.

    0 讨论(0)
  • 2021-01-30 02:00

    Check if you imported the header files of classes that are throwing this error.

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