swift - swift 是否有类似于 CustomStringConvertible 的协议(protocol)来进行冗长的多行打印?

标签 swift

在 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 a CustomStringConvertible's description property.

关于swift - swift 是否有类似于 CustomStringConvertible 的协议(protocol)来进行冗长的多行打印?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38295955/

相关文章:

ios - 在 iOS UITesting 中获取包含另一个带有静态文本的元素的元素

swift - "explicitly"如何在 swift 中实现协议(protocol)?如果不可能,为什么?

ios - 我的 swift - Realm 应用程序因不兼容的库版本问题而崩溃

ios - 以编程方式添加 UITableView

ios - 单独类中的 UIAlertViewDelegate

快速将 1 周添加到当前日期

ios - Swift:视觉格式语言:填充标签和修复按钮

ios - UIPopoverBackgroundView contentViewInsets 必须由子类实现

swift - 如何快速删除节点并添加新节点

swift - HTTP GET 请求时出现 Cloudant 函数子句错误