April 2017
Intermediate to advanced
316 pages
9h 33m
English
In an OOP application, objects are the runtime entities or instances that take space in memory, and more specifically, in the heap. Objects have an associated/allocated memory address to store their state and a set of functions or methods that define the suitable operations on the object state. In short, in OOP, an object encapsulates state and behavior.
To create an object, a blueprint or recipe is required, which is called a class in OOP.
The following section will explore the class concept in more detail. For now, we will define a very simple class in order to be able to talk about objects:
class User { let name = "Constant name" var age: Int = 0 func incrementUserAgeByOne() { self.age += 1 } }
In this example, name and ...
Read now
Unlock full access