How to make an enum conform to a protocol in Swift?

前端 未结 15 1282
终归单人心
终归单人心 2020-12-22 16:32

Swift documentation says that classes, structs, and enums can all conform to protocols, and I can get to a point where they all conform. But I can

15条回答
  •  攒了一身酷
    2020-12-22 17:19

    It is not possible to define variables without getter and setter in enums and therefore it is impossible to have a variable that you can modify.

    You can conform to the protocol but you cannot have same behavior with mutating as in classes.

提交回复
热议问题