Member-only story
Properties in Swift
The values you use every day
Properties are the association of a value with a class, struct or enum. But it can be quite confusing to the beginner that we can have stored or computed properties, and that they can even be lazy.
The idea of this particular tutorial is to make these terms slightly easier to understand, and provide a nice reference.
Difficulty: Beginner | Easy | Normal | Challenging
Prerequisites:
- Be able to produce a “Hello, World!” iOS application (guide HERE)
- Understand the difference between a class and a struct (tutorial HERE)
Terminology
Computed Property: A value that is computed (rather than set)
Property: An association of a value with a class, structure or enumeration
Stored Property: A constant or variable that is stored as part of a class or a struct
Value: A possible result of an implementation
Properties
A rectangle can be represented by the following struct: