Step into Swift logo

What is a Class in Swift?

Class

Class

  • Reference type.
  • Stored on the heap.
  • Can be inherited.
  • It is a blueprint.
  • An object is an instance of a class.
  • Type casting done at runtime.
  • Includes a deinit - Clean up resources in class lifecycle.
  • Can be more than one reference to a class.
  • No memberwise initializer.
  • Use when we need Objective-C interoperability.
  • Use when you need to control identity of data.
  • Class inheritance only with other classes.

Example:

class UserAccountViewController: UIViewController {
  ...
}

Related articles:


< All Posts