We can use the customMirror
property of a string to return the mirror that reflects the String instance.
string.customMirror
This property returns the mirror that reflects the string string
.
Let’s look at the code below:
// create some stringslet name = "Theodore"let language = "Swift"let emptyString = ""// get customMirror propertylet debugDesc1 = name.customMirrorlet debugDesc2 = language.customMirrorlet debugDesc3 = emptyString.customMirror// print resultsprint(debugDesc1)print(debugDesc2)print(debugDesc3)
customMirror
properties of the strings we created.