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

后端 未结 9 1178
心在旅途
心在旅途 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:47

    There are two related error messages that may tell you something is wrong with declarations and/or imports.

    The first is the one you are referring to, which can be generated by NOT putting an #import in your .m (or .pch file) while declaring an @class in your .h.

    The second you might see, if you had a method in your States class like:

    - (void)logout:(NSTimer *)timer
    

    after adding the #import is this:

    No visible @interface for "States" declares the selector 'logout:'

    If you see this, you need to check and see if you declared your "logout" method (in this instance) in the .h file of the class you're importing or forwarding.

    So in your case, you would need a:

    - (void)logout:(NSTimer *)timer;
    

    in your States class's .h to make one or both of these related errors disappear.

提交回复
热议问题