The customMirror
property of a dictionary
returns a Mirror
that reflects that dictionary
. A Mirror
in Swift is used to show the parts that make up a particular object. The object could be a string, double, or dictionary value. The parts it will show can be the object’s stored properties, collection, and so on.
dictionary.customMirror
The property returned is the Mirror
for the dictionary (for example, dict
).
// create a dictionarylet dict = ["a" : "Apple","b" : "Beta","c" : "coding","d" : "developer","e" : "edpresso"]// get the mirrorprint(dict.customMirror)
Lines 2–8: We created a dictionary dict
. Then, we initialize it with some key-value pairs.
Line 11: We got the Mirror
of the dictionary using the customMirror
and print the result to the console.