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

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

    If you are getting this error while trying to use Swift class or method in Objective C: you forgot one of 2 steps Apple defined on this diagram:

    Example:

    Error shows up in your Test.m file:

    Receiver 'MyClass' for class message is a forward declaration

    Step 1: check that Test.h has

    @class MyClass;
    

    Step 2: find *-Swift.h file name in Build Settings (look for Objective-C Generated Interface Header Name). Name will be something like MyModule-Swift.h

    Step 3: check that Test.m imports the above header

    #import "MyModule-Swift.h"
    

提交回复
热议问题