Add field to listing in Swift

I am dealing with enumeration and subclass in Swift. Each child brings their new properties that need to be stored in Enum. This listing is declared with some values โ€‹โ€‹in the mother class. I would like to add value to this listing. I canโ€™t figure out how to do this, I tried this to no avail:

extension MotherClass { enum Enumeration { case NewProperty } } 
+5
source share
1 answer

The only way to add elements to enum is to add them directly to its declaration. You cannot add more elements to enum through inheritance or any other extension mechanism: enum must be fully defined at the point of declaration.

+11
source

Source: https://habr.com/ru/post/1200021/


All Articles