You can define properties of a type to either be associated with the type itself (these are called Type properties), but you can also define properties to be associated with a specific instance of that type.
Type properties are usually used when you want to define something that is the same for each instance of a type and hence you shouldn’t be able to change it specifically for each instance and you should be able to access it using the type itself without having to create an instance.
You can declare type properties using the static
keyword.
class MyClass {
static let typeProperty = "Type"
let instanceProperty = "Instance"
}
You can access the type property from the type itself:
let typeProp = MyClass.typeProperty
But to access an instance property, you need to create an instance of the type:
let instance = MyClass()
let instanceProp = instance.instanceProperty
solved Type Properties In Swift [duplicate]