Swift language provides properties for class, enumeration or structure to associate values.
Properties can be further classified into Stored properties and Computed properties.
Difference between Stored Properties and Computed Properties
Stored Property Computed PropertyStore constant and variable values as
instanceCalculate a value rather than storing the
valueProvided by classes and structuresProvided by classes, enumerations and
structuresBoth Stored and Computed properties are associated with instances type. When the
properties are associated with its type values then it is defined as 'Type Properties'. Stored
and computed properties are usually associated with instances of a particular type.
However, properties can also be associated with the type itself. Such properties are known
as type properties. Property observers are also used
To observe the value of the stored properties To observe the property of inherited subclass derived from superclassStored Properties
Swift introduces Stored Property concept to store the instances of constants and variables.
Stored properties of constants are defined by the 'let' keyword and Stored properties of
variables are defined by the 'var' keyword.
During definition Stored property provides 'default value' During Initialization the user can initialize and modify the initial valuesstruct Number
{
var digits: Int
let pi = 3.1415
}var n = Number(digits: 12345 )n.digits = 67