swift 定义类方法(type methed)
swift 中声明结构体或者枚举的类型方法,需要在func前加上关键字 ststic ,但是如果要定义一个类的类方法时,需要用关键字 class
class SomeClass {
class func someTypeMethod() {
//定义类方法
}
}
SomeClass.someTypeMethod()
//类可以直接用点语法调用这个方法

浙公网安备 33010602011771号