Swift中的"description"

如果要打印对象信息,在OC 中用到 description方法,在 swift 中需要遵守协议 DebugPrintable

extension <#className#>: DebugPrintable {
    override var debugDescription: String {
        return "description"
    }
}

注意: 不能直接输出对象
使用方式应该为 println(obj.debugDescription)

原文地址:https://www.cnblogs.com/coderkl/p/4320292.html