Swift CustomStringConvertibleプロトコル
概要
CustomStringConvertible Document
構造体・クラスインスタンスのprint時に表示する文字列を実装。
JavaのtoString()の様なもの。
example
import Foundation
struct XYZ {
let name = "XYZ構造体"
}
extension XYZ: CustomStringConvertible {
var description: String {
return "関数 : \(name)"
}
}
let xyz = XYZ()
print(xyz)





