Reflection
suggest changeVersions
[{“Name”:“development began (first commit)”,“GroupName”:null}]
Syntax
- 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
Remarks
- 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
.
- 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
.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents