How can you make a property optional in Swift?

We have to declare a question mark ??’ in the code to make a property optional. If a property doesn’t have a value, then the symbol ? helps to avoid the runtime error.

In Swift, you can make a property optional by declaring it with a question mark ? after its type. This indicates that the property can either hold a value of the specified type or be nil, meaning it has no value.

Here’s an example:

var optionalProperty: Int?

In this case, optionalProperty can hold an integer value or be nil.