Structure

Mirror

Representation of the sub-structure and optional “display style” of any arbitrary subject instance.

Overview

Describes the parts—such as stored properties, collection elements, tuple elements, or the active enumeration case—that make up a particular instance. May also supply a “display style” property that suggests how this structure might be rendered.

Mirrors are used by playgrounds and the debugger.

Topics

Querying Descendants

func descendant(MirrorPath, MirrorPath...)

Return a specific descendant of the reflected subject, or nil Returns a specific descendant of the reflected subject, or nil if no such descendant exists.

Type Aliases

typealias Mirror.Child

An element of the reflected instance’s structure. The optional label may be used when appropriate, e.g. to represent the name of a stored property or of an active enum case, and will be used for lookup when Strings are passed to the descendant method.

typealias Mirror.Children

The type used to represent sub-structure.

Initializers

init<Subject, C>(Subject, children: C, displayStyle: Mirror.DisplayStyle?, ancestorRepresentation: Mirror.AncestorRepresentation)

Represent subject with structure described by children, using an optional displayStyle.

init<Subject, C>(Subject, unlabeledChildren: C, displayStyle: Mirror.DisplayStyle?, ancestorRepresentation: Mirror.AncestorRepresentation)

Represent subject with child values given by unlabeledChildren, using an optional displayStyle. The result’s child labels will all be nil.

init(reflecting: Any)

Reflect upon the given subject.

Instance Properties

let children: Mirror.Children

A collection of Child elements describing the structure of the reflected subject.

let displayStyle: Mirror.DisplayStyle?

Suggests a display style for the reflected subject.

let subjectType: Any.Type

The static type of the subject being reflected.

Enumerations

enum Mirror.AncestorRepresentation

Representation of ancestor classes.

enum Mirror.DisplayStyle

A suggestion of how a Mirror’s subject is to be interpreted.

Relationships

See Also

Querying Runtime Values

struct ObjectIdentifier

A unique identifier for a class instance or metatype.

func type<T, Metatype>(of: T)

Returns the dynamic type of a value.

func ==(Any.Type?, Any.Type?)

Returns true iff t0 is identical to t1; i.e. if they are both nil or they both represent the same type.

func !=(Any.Type?, Any.Type?)

Returns false iff t0 is identical to t1; i.e. if they are both nil or they both represent the same type.