I have Enum , which contains the other enum:

  enum Products { enum A { case bla case blabla static var name = { return "It's product A" } } enum B { case mnym case mnymmnym static var name = { return "It's product B" } } let allProductsType: [Any] = [A.self, B.self] } 

I want to write some function that can be iterated through the array allProductsType and return me an element to which I could refer: element.name. Is it possible to do this? And if so, how?

  • As a result, I made a function that takes a generic type, iterates over an array of types, and returns a specific property to me. It works, but I don’t really like it. Somehow it is not particularly clean. As a result, to get some property of this type, I need to create different functions that will return what I need. But it works - Dmitriy Greh
  • The purpose of this is not entirely clear. From what is presented, the best is the protocol. - VAndrJ

0