Swift CustomStringConvertible 协议的使用

前言

先看一下Swift标准库中对CustomStringConvertible协议的定义

public protocol CustomStringConvertible {
   
    
    
    /// A textual representation of this instance.
    ///
    /// Calling this property directly is discouraged. Instead, convert an
    /// instance of any type to a string by using the `String(describing:)`
    /// initializer. This initializer works with any type, and uses the custom
    /// `description` property for types that conform to
    /// `CustomStringConvertible`:
    

猜你喜欢

转载自blog.csdn.net/zhanglei5415/article/details/125715772