What's the difference between a protocol extended from AnyObject and a class-only protocol?

前端 未结 6 1917
一整个雨季
一整个雨季 2020-12-02 14:30

Both this declaration

protocol SomeProtocol : AnyObject {
}

and this declaration

protocol SomeProtocol : class {
}
<         


        
6条回答
  •  伪装坚强ぢ
    2020-12-02 14:36

    I misspoke before. @MartinR should really answer this, since he's the one who corrected me and provided the correct information.

    The real difference is that a protocol with the class qualifier can only be applied to a class, not a struct or enum.

    Martin, why don't you answer and the OP can accept your answer?

提交回复
热议问题