StructureSwift

Mirror

A representation of the substructure and display style of an instance of any type.

struct Mirror

Overview

A mirror describes the parts that make up a particular instance, such as the instance’s stored properties, collection or tuple elements, or its active enumeration case. Mirrors also provide a “display style” property that suggests how this mirror might be rendered.

Playgrounds and the debugger use the Mirror type to display representations of values of any type. For example, when you pass an instance to the dump(_:_:_:_:) function, a mirror is used to render that instance’s runtime contents.

struct Point {
    let x: Int, y: Int
}

let p = Point(x: 21, y: 30)
print(String(reflecting: p))
// Prints "▿ Point
//           - x: 21
//           - y: 30"

To customize the mirror representation of a custom type, add conformance to the CustomReflectable protocol.

Members

Typealiases

Initializers

Instance Properties

Instance Methods

Enumerations

Conforms To