在 Swift 2.2 中,提供的协议(protocol) CustomStringConvertible
提供了一个返回字符串表示的计算属性。通常,它用于简单数据类型的简短单行字符串表示。
是否有类似的协议(protocol)、约定或设施来为类提供更冗长的多行描述性字符串表示形式?
最佳答案
您正在寻找CustomDebugStringConvertible
This textual representation is used when values are written to an output stream by
debugPrint
, and is typically more verbose than the text provided by aCustomStringConvertible
's description property.
关于swift - swift 是否有类似于 CustomStringConvertible 的协议(protocol)来进行冗长的多行打印?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38295955/