How to conform to a self-made protocol?

后端 未结 7 1798
忘了有多久
忘了有多久 2021-02-10 16:33

I have a class with an delegate property. Anyone who wants to be a delegate must conform to a protocol. I defined everything like this:

#import 

        
7条回答
  •  自闭症患者
    2021-02-10 17:11

    I think you need to #import the header file that defines the protocol. How can the compiler know which methods are available without it?

    If you use another class (i.e., as an ivar or as a parameter to a method) then you can use a forward declaration. But if you subclass then you need to #import.

提交回复
热议问题