Candidate is not '@objc' but protocol requires it

后端 未结 4 543
余生分开走
余生分开走 2021-02-13 22:33

I have been following this tutorial to learn swift & iOS app development. In the Protocol section, the tutorial defined the following protocol:

@objc protoco         


        
4条回答
  •  南方客
    南方客 (楼主)
    2021-02-13 23:29

    In order for a type to conform to a protocol marked @objc, that type must also marked with @objc or the methods being used to satisfy the protocol must be.

    Using @objc on a declaration tells the compiler to expose it to the Objective-C runtime. In order for that to be possible, the type that was declared @objc must be able to be represented in Objective-C.

    For classes this means they must inherit from NSObject. For methods, this means they become backed by dynamic Objective-C message passing.

提交回复
热议问题