Arilson Karmo Arilson Karmo - 4 months ago 11
Swift Question

Whats a difference between static function and non Static in Swift?

I have model and in this model contains a function to SUM 1 + 1
Why should I have to make this function non-static?

The difference is an only instantiable class or not?

Calling static function in Controller


Calling non-static function in Controller

let model = Model()

What's a real difference?


The difference is that SubClass of your model class can override non static function whether is class or instance. but SubClass can't override static function.

And the reason behind that is static get one time memory allocation and remains in memory until class remains in memory!