enum Mirror.AncestorRepresentation

Representation of ancestor classes.

A CustomReflectable class can control how its mirror will represent ancestor classes by initializing the mirror with a AncestorRepresentation. This setting has no effect on mirrors reflecting value type instances.

Import import Swift


case Generated

Generate a default mirror for all ancestor classes. This is the default behavior.

Note: This option bypasses any implementation of customMirror that may be supplied by a CustomReflectable ancestor, so this is typically not the right option for a customMirrorimplementation Generate a default mirror for all ancestor classes.

This case is the default.

Note: This option generates default mirrors even for ancestor classes that may implement CustomReflectable's customMirror requirement. To avoid dropping an ancestor class customization, an override of customMirror() should pass ancestorRepresentation: .Customized(super.customMirror) when initializing its Mirror.


case Customized(() -> Mirror)

Use 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":

func customMirror() -> Mirror {
  return Mirror(
    children: ["someProperty": self.someProperty],
    ancestorRepresentation: .Customized(super.customMirror)) // <==


case Suppressed

Suppress the representation of all ancestor classes. The resulting Mirror's superclassMirror() is nil.