Swift Struct and Class
-
They can define attributes to store values, or they can define functions -
They can define subscripts to provide access to values subscript syntax (Subscript Syntax) -
They can define initializers to set their initial state, using init() -
Extensions in Swift Explained
-
Class can inherit from another class, just like creating its own view controller subclass from -
Class can be de initialized, that is, you can call a function before the class is destroyed -
Class is a reference type( Reference Type ), structure is value type
-
Simple data type -
In a multithreaded environment -
When most properties of the structure are also value types
-
It can inherit from another class, which is impossible to do with structure -
Classes can be initialized, that is, they can implement a deinit Function, you can make one or more references to the same class (that is, the class is a reference type) -
Class has built-in concepts identity Identity, you can check whether two references (variables, constants, attributes, etc.) refer to the same object