Swift CustomStringConvertible 发表于 2017-02-10 | 自定义输出,必须遵循 CustomStringConvertible 协议,实现 description 方法: 123456789101112131415class Person: CustomStringConvertible { var name: String var age: Int init(name:String, age:Int) { self.name = name self.age = age } var description: String{ return name + String(age) }}let person = Person(name: "JY", age: 25)print(person)