The Swift Reflection API and what you can do with it

Classes or Structs

released Fri, 01 Mar 2019
Swift Version 5.0

Classes or Structs

The second can be used for a class or a struct.

init<Subject>(_ subject: Subject, children: KeyValuePairs<String, Any>, displayStyle: Mirror.DisplayStyle? = nil, ancestorRepresentation: Mirror.AncestorRepresentation = .generated)

Interesting to note, here, is that you provide the children (i.e. properties) of your subject as a KeyValuePairs<String, Any> which is a bit like a dictionary only that it can be used directly as function parameters.