https://stackoverflow.com/questions/29636633/static-vs-class-functions-variables-in-swift-classes
static and class both associate a method with a class, rather than an instance of a class.
The difference is that subclasses can override class methods; they cannot override static methods.
Cannot override final functions
Finally, you can finalize your override like so:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
class A { class func classFunction(){ print("\(type(of:self)) - \(#function)") } static func staticFunction() { print("\(type(of:self)) - \(#function)") } final func finalFunc() { print("\(type(of:self)) - \(#function)") } class func classFunctionToBeMakeFinalInImmediateSubclass(){ print("\(type(of:self)) - \(#function)") } } class B : A { override class func classFunction() { print("\(type(of:self)) - \(#function)") } override final class func classFunctionToBeMakeFinalInImmediateSubclass(){ print("\(type(of:self)) - \(#function)") } } A.classFunction() A.staticFunction() A.classFunctionToBeMakeFinalInImmediateSubclass() B.classFunction() B.classFunctionToBeMakeFinalInImmediateSubclass() |