Mirror.AncestorRepresentation

enum AncestorRepresentation

The representation to use for ancestor classes.

A class that conforms to the CustomReflectable protocol can control how its mirror represents ancestor classes by initializing the mirror with an AncestorRepresentation. This setting has no effect on mirrors reflecting value type instances.

Cases

case customized Required

Uses the nearest ancestor's implementation of customMirror to create a mirror for that ancestor.

Other classes derived from such an ancestor are given a default mirror. The payload for this option should always be { super.customMirror }:

var customMirror: Mirror {
    return Mirror(
        self,
        children: ["someProperty": self.someProperty],
        ancestorRepresentation: .customized({ super.customMirror })) // <==
}

Declaration

case customized(: () -> Mirror)
case generated Required

Generates a default mirror for all ancestor classes.

This case is the default when initializing a Mirror instance.

When you use this option, a subclass's mirror generates default mirrors even for ancestor classes that conform to the CustomReflectable protocol. To avoid dropping the customization provided by ancestor classes, an override of customMirror should pass .customized({ super.customMirror }) as ancestorRepresentation when initializing its mirror.

Declaration

case generated
case suppressed Required

Suppresses the representation of all ancestor classes.

In a mirror created with this ancestor representation, the superclassMirror property is nil.

Declaration

case suppressed