Swift文档说
debugDescription = A textual representation of self, suitable for debugging
description = A textual representation of self
Run Code Online (Sandbox Code Playgroud)
在操场上,我得到两个呼叫的输出相同
anArray.debugDescription // "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
anArray.description // "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
Run Code Online (Sandbox Code Playgroud)
两者之间的实际区别是什么?
对象的调试描述与其描述相同。但是,如果您想将它们解耦,则可以重写debugDescription;否则,请参见。许多可可粉都这样做。
因此,基本上,除非您在debugDescription中添加任何其他功能,否则它将与description相同。