Swift LanguageReflection

Download Swift Language for free


  • Mirror(reflecting: instance) // Initializes a mirror with the subject to reflect
  • mirror.displayStyle // Display style used for Xcode playgrounds
  • mirror.description // Textual representation of this instance, see CustomStringConvertible
  • mirror.subjectType // Returns the type of the subject being reflected
  • mirror.superclassMirror // Returns the mirror of the super-class of the subject being reflected


  1. General Remarks:

A Mirror is a struct used in the introspection of an object in Swift. Its most prominent property is the children array. One possible use case is to serialize a struct for Core Data. This is done by converting a struct into a NSManagedObject.

  1. Basic Usage for Mirror Remarks:

The children property of a Mirror is an array of child objects from the object the Mirror instance is reflecting. A child object has two properties label and value. For example a child might be a property with the name title and the value of Game of Thrones: A Song of Ice and Fire.

Related Examples

Basic Usage for Mirror