Swift protocol in Objective-C class

前端 未结 6 486
灰色年华
灰色年华 2021-02-02 06:39

I wrote SearcherProtocol in Swift and need to implement an Objective-C class FileSearcher which has to use this protocol.

So I tried this:

6条回答
  •  猫巷女王i
    2021-02-02 07:01

    Make sure you are including the auto generated Swift header in your ObjectiveC file. It will have the same name as your project module followed by -Swift.h.

    For instance if your Project Module is MyTarget, then you would use:

    #import "MyTarget-Swift.h"

    If you are typing in the import into your Objective C file, it will not autocomplete. You can verify that you have the correct file by Command-clicking on the header after typing it in.

提交回复
热议问题