What is an Object?
An object is an instance or a specific example of a class. An object has its values for the properties and can use the methods defined by the class. For example, bike1 is an object of the Bike class.
Declaration of Objects
We use the class name followed by parentheses to create an object of a class.
Syntax:
var objectName = ClassName()
For example, we can create another object of the Bike class as follows:
var bike2 = Bike()
Class and Object in Swift
Swift is an object-oriented programming language that supports the concept of classes and objects. In this article, we will learn what are classes and objects, how to define them, and how to use them in Swift.