Along with different types of properties Swift supports a special type of property && should be used in a special manner. The property is of Class type. It is very important type that Swift has to offer. This type of property is basically just like a function && usually you call it closure. If you are using Class type property the you should understand that Swift doesn't support class- type property unless the properties are computed type. Means to say that property should return something. For example:
class var class_property : Int {
var integerNumber1 = 20
var integerNumber2 = 50
var integerNumber3 = integerNumber1 * integerNumber2
return integerNumber3
//class type property returning something (computed property)
}()
"class var class_property : Int()"
var variable = ClassProperty.class_property
Now value of "variable" is 100.
class var class_property : Int {
var integerNumber1 = 20
var integerNumber2 = 50
var integerNumber3 = integerNumber1 * integerNumber2
return integerNumber3
//class type property returning something (computed property)
}()
As you can see in the above mentioned example that you can make a property a class type just by adding "class" keyword && the property should return something as in above example property returning Integer type value so is computed property.
You can't use class type property as follows:
This is an error in Swift because Swift doesn't support class property in this way.
Class property are called by using "<class_name>.<property_name>" syntax means class_name is perfix if you want to make a call to the class property.For example if I want to call the above mentioned property let its class is "ClassProperty", for example then I will call it in this way:
var variable = ClassProperty.class_property
Now value of "variable" is 100.