What is the debugDescription property of a dictionary in Swift?
Overview
When we use the debugDescription property of a dictionary instance on a dictionary, we want to get the string that represents the contents of that dictionary. This property is useful and suitable for debugging.
Syntax
dictionary.debugDescription
Return value
The value returned is a string.
Code example
// create some dictionariesvar days = [0 : "Sunday",1 : "Monday",2 : "Tuesday",3 : "Wednesday",4 : "Thursday",5 : "Friday",6 : "Saturday"]// get the debug descriptionprint(days.debugDescription)
Explanation
- Lines 2 to 10: We create a dictionary called
days. We then give it some entry values. - Line 13: We get the debug description using the
debugDescriptionproperty and print the value to the console.