Static VS Class Keywords

--

Swift allows us to use a static prefix on methods and properties to associate them with the type that they’re declared on rather than the instance.

Static Method

The 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.

Static Property

We all know Instance Properties that belong to an instance of type and every time you create an instance of that type it has its own property value.

But what if you want to create a global property that all instances of the same type share?

This is what we call Static or Type property because it belongs to the Type itself not an instance of it.

There will be always one copy of Type property that all instance can use it.

--

--