类型成员

类

class Config {
    //类型常量
    static let maxConnections = 3

    //6 版本中的类型属性
    nonisolated(unsafe) static var host = ""
    nonisolated(unsafe) static var port = 0

    //类型方法
    static func getConnection() -> String {
        return "\(host):\(port)"
    }
}

Config.host = "10.0.0.1"
Config.port = 52
let connection = Config.getConnection()
//connection is "10.0.0.1:52"

print("connection is \(connection)")